summaryrefslogtreecommitdiff
path: root/src/ipcpd/shim-udp
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2016-05-15 14:39:00 +0200
committerSander Vrijders <sander.vrijders@intec.ugent.be>2016-05-15 14:41:29 +0200
commit561a9a53b08ce764e5134b6306dde0cb3ffaebc2 (patch)
tree85395fa2ac46f49db596f0748cac86a544df8ac6 /src/ipcpd/shim-udp
parenta7cfeec50d962d6c56f9d3e4d60c2d1d49c23734 (diff)
downloadouroboros-561a9a53b08ce764e5134b6306dde0cb3ffaebc2.tar.gz
ouroboros-561a9a53b08ce764e5134b6306dde0cb3ffaebc2.zip
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.
Diffstat (limited to 'src/ipcpd/shim-udp')
-rw-r--r--src/ipcpd/shim-udp/main.c4
1 files 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;