diff options
author | dimitri staessens <[email protected]> | 2017-07-20 14:23:46 +0000 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2017-07-20 14:23:46 +0000 |
commit | 0dacddfff0a705591e6665a00c367c367c23c1f0 (patch) | |
tree | a1948c4b26e494bc1ec3944b011ce5f0936e18c5 /src/lib | |
parent | 3e9cbbabbc70319e44aa12bd6c59746cab3c23f6 (diff) | |
parent | d9faf7baf424667acbcb936f935d1ca22ea0eb6b (diff) | |
download | ouroboros-0dacddfff0a705591e6665a00c367c367c23c1f0.tar.gz ouroboros-0dacddfff0a705591e6665a00c367c367c23c1f0.zip |
Merged in dstaesse/ouroboros/testing-cdap-destroy (pull request #534)
lib: Fix destruction of CDAP instances
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/cdap.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/lib/cdap.c b/src/lib/cdap.c index 16f2c078..c1209138 100644 --- a/src/lib/cdap.c +++ b/src/lib/cdap.c @@ -268,7 +268,7 @@ static void cdap_rcvd_destroy(struct cdap * instance) pthread_mutex_lock(&instance->rcvd_lock); - list_for_each_safe(p, h, &instance->sent) { + list_for_each_safe(p, h, &instance->rcvd) { struct cdap_rcvd * r = list_entry(p, struct cdap_rcvd, next); list_del(&r->next); if (r->data != NULL) @@ -578,15 +578,8 @@ int cdap_del_flow(struct cdap * instance, pthread_rwlock_wrlock(&instance->flows_lock); - pthread_mutex_lock(&instance->mtx); - - while (instance->proc) - pthread_cond_wait(&instance->cond, &instance->mtx); - flow_set_del(instance->set, fd); - pthread_mutex_unlock(&instance->mtx); - list_for_each_safe(p, h, &instance->flows) { struct fd_el * e = list_entry(p, struct fd_el, next); if (e->fd == fd) { @@ -600,6 +593,16 @@ int cdap_del_flow(struct cdap * instance, pthread_rwlock_unlock(&instance->flows_lock); + pthread_mutex_lock(&instance->mtx); + + pthread_cleanup_push((void(*)(void *))pthread_mutex_unlock, + (void *) &instance->mtx); + + while (instance->proc) + pthread_cond_wait(&instance->cond, &instance->mtx); + + pthread_cleanup_pop(true); + return 0; } |