diff options
author | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2016-08-27 23:25:53 +0200 |
---|---|---|
committer | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2016-08-27 23:30:05 +0200 |
commit | 0c41273687df7aaebf8b749a89d4c2ab328bf4c1 (patch) | |
tree | 08c12665f3b9f7aedfc8e7b4fc7184d307878cd2 /src/lib/cdap.c | |
parent | f897c97de0b28cc2e48bba1bb9fc986fe4659819 (diff) | |
download | ouroboros-0c41273687df7aaebf8b749a89d4c2ab328bf4c1.tar.gz ouroboros-0c41273687df7aaebf8b749a89d4c2ab328bf4c1.zip |
cdap: Fix destruction
Destroying NULL should succeed. Resources need to be freed even if
flow_dealloc fails.
Diffstat (limited to 'src/lib/cdap.c')
-rw-r--r-- | src/lib/cdap.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/lib/cdap.c b/src/lib/cdap.c index 5dc050a4..df2128a0 100644 --- a/src/lib/cdap.c +++ b/src/lib/cdap.c @@ -230,12 +230,10 @@ struct cdap * cdap_create(struct cdap_ops * ops, int cdap_destroy(struct cdap * instance) { if (instance == NULL) - return -1; + return 0; pthread_cancel(instance->reader); - - if (flow_dealloc(instance->fd)) - return -1; + pthread_join(instance->reader, NULL); pthread_mutex_lock(&instance->ids_lock); @@ -243,8 +241,7 @@ int cdap_destroy(struct cdap * instance) pthread_mutex_unlock(&instance->ids_lock); - pthread_join(instance->reader, - NULL); + flow_dealloc(instance->fd); free(instance); |