summaryrefslogtreecommitdiff
path: root/src/lib/cdap_req.c
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2017-02-05 12:09:45 +0000
committerSander Vrijders <sander.vrijders@intec.ugent.be>2017-02-05 12:09:45 +0000
commite8082dbffdcb89e7762231e0548cf72c69fbfcca (patch)
tree96e97ca4e3c4dbeb83bf2851cdc41442e7f0720d /src/lib/cdap_req.c
parente3b1288354349edc53c7c3c9ebd3efe23a7df10d (diff)
parent49fb847ff3dc8b7de91eb3a54524e60b145f9bf4 (diff)
downloadouroboros-e8082dbffdcb89e7762231e0548cf72c69fbfcca.tar.gz
ouroboros-e8082dbffdcb89e7762231e0548cf72c69fbfcca.zip
Merged in dstaesse/ouroboros/be-wip (pull request #360)
Be wip
Diffstat (limited to 'src/lib/cdap_req.c')
-rw-r--r--src/lib/cdap_req.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/lib/cdap_req.c b/src/lib/cdap_req.c
index 565cafd0..2f55b107 100644
--- a/src/lib/cdap_req.c
+++ b/src/lib/cdap_req.c
@@ -108,6 +108,7 @@ int cdap_req_wait(struct cdap_req * creq)
}
creq->state = REQ_PENDING;
+ pthread_cond_broadcast(&creq->cond);
while (creq->state == REQ_PENDING) {
ret = -pthread_cond_timedwait(&creq->cond,
@@ -131,13 +132,20 @@ int cdap_req_wait(struct cdap_req * creq)
return ret;
}
-void cdap_req_respond(struct cdap_req * creq, int response, buffer_t data)
+void cdap_req_respond(struct cdap_req * creq,
+ int response,
+ buffer_t data)
{
assert(creq);
pthread_mutex_lock(&creq->lock);
+ while (creq->state == REQ_INIT)
+ pthread_cond_wait(&creq->cond, &creq->lock);
+
if (creq->state != REQ_PENDING) {
+ creq->state = REQ_NULL;
+ pthread_cond_broadcast(&creq->cond);
pthread_mutex_unlock(&creq->lock);
return;
}