From c5b092665c219c679ede91b3dc816c61f2f9dabe Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Wed, 5 Apr 2017 14:28:24 +0200 Subject: ipcpd: Add lock for allocation requests This adds a lock to prevent a race condition between flow_req_arr and flow_alloc_resp. --- src/ipcpd/normal/fmgr.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/ipcpd/normal') 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: -- cgit v1.2.3