summaryrefslogtreecommitdiff
path: root/src/ipcpd/normal
diff options
context:
space:
mode:
authorSander Vrijders <[email protected]>2017-04-05 14:28:24 +0200
committerSander Vrijders <[email protected]>2017-04-05 14:28:24 +0200
commitc5b092665c219c679ede91b3dc816c61f2f9dabe (patch)
treee60083545da6ce0dc5fdacd06610d907b90c5aee /src/ipcpd/normal
parentfa1590539e66c17902bb4f09221e6447b3233bfb (diff)
downloadouroboros-c5b092665c219c679ede91b3dc816c61f2f9dabe.tar.gz
ouroboros-c5b092665c219c679ede91b3dc816c61f2f9dabe.zip
ipcpd: Add lock for allocation requests
This adds a lock to prevent a race condition between flow_req_arr and flow_alloc_resp.
Diffstat (limited to 'src/ipcpd/normal')
-rw-r--r--src/ipcpd/normal/fmgr.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/ipcpd/normal/fmgr.c b/src/ipcpd/normal/fmgr.c
index 19653430..56f1e099 100644
--- a/src/ipcpd/normal/fmgr.c
+++ b/src/ipcpd/normal/fmgr.c
@@ -619,10 +619,12 @@ int fmgr_np1_post_buf(cep_id_t cep_id,
switch (msg->code) {
case FLOW_ALLOC_CODE__FLOW_REQ:
+ pthread_mutex_lock(&ipcpi.alloc_lock);
fd = ipcp_flow_req_arr(getpid(),
msg->dst_name,
msg->qoscube);
if (fd < 0) {
+ pthread_mutex_unlock(&ipcpi.alloc_lock);
flow_alloc_msg__free_unpacked(msg, NULL);
log_err("Failed to get fd for flow.");
return -1;
@@ -634,6 +636,7 @@ int fmgr_np1_post_buf(cep_id_t cep_id,
fmgr.np1_cep_id_to_fd[cep_id] = fd;
pthread_rwlock_unlock(&fmgr.np1_flows_lock);
+ pthread_mutex_unlock(&ipcpi.alloc_lock);
break;
case FLOW_ALLOC_CODE__FLOW_REPLY: