diff options
author | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2016-05-10 12:01:39 +0200 |
---|---|---|
committer | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2016-05-10 12:01:39 +0200 |
commit | 2407d44fbe3a7ead5c7be0231688d114e009bc51 (patch) | |
tree | 8bf40f5d923f10c7231b7b6b922a6ade8c21fe55 /src/irmd/main.c | |
parent | a704cdbb3fd038b1550047f4a22059983019290f (diff) | |
download | ouroboros-2407d44fbe3a7ead5c7be0231688d114e009bc51.tar.gz ouroboros-2407d44fbe3a7ead5c7be0231688d114e009bc51.zip |
irmd: fixed potential data races
bmp_allocate should be called under lock. Helgrind does not give
warnings anymore during flow allocation.
Diffstat (limited to 'src/irmd/main.c')
-rw-r--r-- | src/irmd/main.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/irmd/main.c b/src/irmd/main.c index f4c203e0..f8a5f2d5 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -440,7 +440,7 @@ static int destroy_ipcp(instance_name_t * api) return 0; } - pid =api->id; + pid = api->id; if (ipcp_destroy(api->id)) LOG_ERR("Could not destroy IPCP."); @@ -837,13 +837,14 @@ static struct port_map_entry * flow_alloc(pid_t pid, return NULL; } - pme->port_id = bmp_allocate(instance->port_ids); pme->n_pid = pid; pme->state = FLOW_PENDING; - pme->n_1_pid = get_ipcp_by_dst_name(dst_name)->id; pthread_mutex_lock(&instance->r_lock); + pme->port_id = bmp_allocate(instance->port_ids); + pme->n_1_pid = get_ipcp_by_dst_name(dst_name)->id; + list_add(&pme->next, &instance->port_map); ipcp = get_ipcp_by_dst_name(dst_name); @@ -960,12 +961,13 @@ static struct port_map_entry * flow_req_arr(pid_t pid, return NULL; } - pme->port_id = bmp_allocate(instance->port_ids); pme->state = FLOW_PENDING; pme->n_1_pid = pid; pthread_mutex_lock(&instance->r_lock); + pme->port_id = bmp_allocate(instance->port_ids); + rne = get_reg_name_entry_by_name(dst_name); if (rne == NULL) { pthread_mutex_unlock(&instance->r_lock); @@ -974,7 +976,7 @@ static struct port_map_entry * flow_req_arr(pid_t pid, return NULL; } - pme->n_pid = rne->api->id; + pme->n_pid = rne->api->id; list_add(&pme->next, &instance->port_map); @@ -983,11 +985,11 @@ static struct port_map_entry * flow_req_arr(pid_t pid, rne->flow_arrived = true; - pthread_mutex_unlock(&instance->r_lock); - if (pthread_cond_signal(&rne->acc_signal)) LOG_ERR("Failed to send signal."); + pthread_mutex_unlock(&instance->r_lock); + return pme; } @@ -1015,9 +1017,9 @@ static int flow_alloc_reply(int port_id, else e->state = FLOW_NULL; - pthread_mutex_unlock(&instance->r_lock); if (pthread_cond_signal(&e->res_signal)) LOG_ERR("Failed to send signal."); + pthread_mutex_unlock(&instance->r_lock); return 0; } |