From 50193f69a256cacd27ae74dc0ab01d44a40c6f5a Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Thu, 12 May 2016 18:13:45 +0200 Subject: irmd: fixed bad locking and added cleanup flow_alloc_res had missing cleanup, added missing unlock. --- src/irmd/main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/irmd/main.c b/src/irmd/main.c index aba69224..d266273d 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -1006,12 +1006,16 @@ static int flow_alloc_res(int port_id) } pthread_mutex_unlock(&instance->r_lock); - pthread_mutex_lock(&e->res_lock); while (true) { + pthread_mutex_lock(&e->res_lock); + pthread_cleanup_push((void(*)(void *))pthread_mutex_unlock, + (void*) &e->res_lock); + pthread_cond_wait(&e->res_signal, &e->res_lock); pthread_mutex_unlock(&e->res_lock); + pthread_cleanup_pop(0); pthread_mutex_lock(&instance->r_lock); e = get_port_map_entry(port_id); @@ -1032,6 +1036,7 @@ static int flow_alloc_res(int port_id) } /* still pending, spurious wake */ + pthread_mutex_unlock(&instance->r_lock); } pthread_mutex_unlock(&instance->r_lock); -- cgit v1.2.3