summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2016-05-12 18:22:21 +0200
committerSander Vrijders <sander.vrijders@intec.ugent.be>2016-05-12 18:22:21 +0200
commitf17e50d1cf867fd38b46932187a819e15c1274bc (patch)
tree1093bd9828f5f09a837f3a7ca52d75b2fe53c88a /src
parent488bc8790ab3611ab4b0ccaefb9fefce951501c0 (diff)
parent50193f69a256cacd27ae74dc0ab01d44a40c6f5a (diff)
downloadouroboros-f17e50d1cf867fd38b46932187a819e15c1274bc.tar.gz
ouroboros-f17e50d1cf867fd38b46932187a819e15c1274bc.zip
Merged in dstaesse/ouroboros/be-irmd (pull request #78)
irmd: fixed bad locking and added cleanup
Diffstat (limited to 'src')
-rw-r--r--src/irmd/main.c7
1 files changed, 6 insertions, 1 deletions
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);