summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-03-31 20:36:45 +0200
committerdimitri staessens <dimitri.staessens@ugent.be>2017-04-01 14:25:39 +0200
commit014daf9684e85566cfcf44ec107c8cb792df3b14 (patch)
treedff3b7eb4be77771577f895887e6afe1f6b60d64 /src
parentff3e622ce3f686c38848dcc3aedcbf380c631910 (diff)
downloadouroboros-014daf9684e85566cfcf44ec107c8cb792df3b14.tar.gz
ouroboros-014daf9684e85566cfcf44ec107c8cb792df3b14.zip
lib: Some fixes in CDAP
Diffstat (limited to 'src')
-rw-r--r--src/lib/cdap.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/lib/cdap.c b/src/lib/cdap.c
index 824f2c5d..f0db2419 100644
--- a/src/lib/cdap.c
+++ b/src/lib/cdap.c
@@ -183,8 +183,8 @@ static struct cdap_rcvd * cdap_rcvd_get_by_key(struct cdap * instance,
list_for_each_safe(p, h, &instance->rcvd) {
rcvd = list_entry(p, struct cdap_rcvd, next);
if (rcvd->key == key) {
- pthread_mutex_unlock(&instance->rcvd_lock);
list_del(&rcvd->next);
+ pthread_mutex_unlock(&instance->rcvd_lock);
return rcvd;
}
}
@@ -669,6 +669,7 @@ cdap_key_t * cdap_request_send(struct cdap * instance,
pthread_rwlock_unlock(&instance->flows_lock);
release_id(instance, *key);
release_id(instance, iid);
+ *key = INVALID_CDAP_KEY;
return keys;
}
@@ -678,13 +679,17 @@ cdap_key_t * cdap_request_send(struct cdap * instance,
cdap_sent_del(instance, req);
release_id(instance, *key);
release_id(instance, iid);
+ *key = INVALID_CDAP_KEY;
return keys;
}
if (ret < 0) {
+ pthread_rwlock_unlock(&instance->flows_lock);
cdap_sent_del(instance, req);
release_id(instance, *key);
release_id(instance, iid);
+ *key = INVALID_CDAP_KEY;
+ return keys;
}
++key;
@@ -717,6 +722,7 @@ int cdap_reply_wait(struct cdap * instance,
if (ret < 0) {
cdap_sent_del(instance, r);
release_id(instance, iid);
+ release_id(instance, key);
return ret;
}
@@ -731,6 +737,7 @@ int cdap_reply_wait(struct cdap * instance,
cdap_sent_del(instance, r);
release_id(instance, iid);
+ release_id(instance, key);
return ret;
}
@@ -766,6 +773,8 @@ cdap_key_t cdap_request_wait(struct cdap * instance,
}
}
+ assert(rcv->proc == false);
+
rcv->proc = true;
list_del(&rcv->next);
list_add_tail(&rcv->next, &instance->rcvd);