From 561a9a53b08ce764e5134b6306dde0cb3ffaebc2 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Sun, 15 May 2016 14:39:00 +0200 Subject: ipcpd: Move lock in ipcp_udp_listener This takes a lock before notifying the IRMd of a new flow request, to avoid race conditions when trying to retrieve the fd by port-id. --- src/ipcpd/shim-udp/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c index 9c295e30..74fa0d2b 100644 --- a/src/ipcpd/shim-udp/main.c +++ b/src/ipcpd/shim-udp/main.c @@ -395,6 +395,7 @@ static void * ipcp_udp_listener() } /* reply to IRM */ + rw_lock_wrlock(&_ap_instance->flows_lock); port_id = ipcp_flow_req_arr(getpid(), buf, @@ -404,11 +405,10 @@ static void * ipcp_udp_listener() if (port_id < 0) { LOG_ERR("Could not get port id from IRMd"); close(fd); + rw_lock_unlock(&_ap_instance->flows_lock); continue; } - rw_lock_wrlock(&_ap_instance->flows_lock); - _ap_instance->flows[fd].port_id = port_id; _ap_instance->flows[fd].rb = NULL; _ap_instance->flows[fd].state = FLOW_PENDING; -- cgit v1.2.3