diff options
author | dimitri staessens <dimitri.staessens@ugent.be> | 2017-03-31 12:40:46 +0000 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@ugent.be> | 2017-03-31 12:40:46 +0000 |
commit | e39e93447d8da3bf06b8f5aecd3daf41c0451f81 (patch) | |
tree | 2a8bf2d55abe85660e3fd3b3bd97114d63107006 /src/lib | |
parent | 02523d780b9c629a98e863b5218f054cde2f0426 (diff) | |
parent | 9f33d70fc92d2f0f7b6058765049bfcb41e2cca9 (diff) | |
download | ouroboros-e39e93447d8da3bf06b8f5aecd3daf41c0451f81.tar.gz ouroboros-e39e93447d8da3bf06b8f5aecd3daf41c0451f81.zip |
Merged in dstaesse/ouroboros/be-cdap-cancel (pull request #442)
lib: Cancel outstanding CDAP requests on destroy
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/cdap.c | 1 | ||||
-rw-r--r-- | src/lib/cdap_req.c | 13 | ||||
-rw-r--r-- | src/lib/cdap_req.h | 2 |
3 files changed, 15 insertions, 1 deletions
diff --git a/src/lib/cdap.c b/src/lib/cdap.c index 38806c23..b04dcf51 100644 --- a/src/lib/cdap.c +++ b/src/lib/cdap.c @@ -250,6 +250,7 @@ static void cdap_sent_destroy(struct cdap * instance) list_for_each_safe(p, h, &instance->sent) { struct cdap_req * req = list_entry(p, struct cdap_req, next); list_del(&req->next); + cdap_req_cancel(req); cdap_req_destroy(req); } diff --git a/src/lib/cdap_req.c b/src/lib/cdap_req.c index 0b77f266..df748058 100644 --- a/src/lib/cdap_req.c +++ b/src/lib/cdap_req.c @@ -175,3 +175,16 @@ void cdap_req_respond(struct cdap_req * creq, pthread_mutex_unlock(&creq->lock); } + + +void cdap_req_cancel(struct cdap_req * creq) +{ + assert(creq); + + pthread_mutex_lock(&creq->lock); + + creq->state = REQ_NULL; + pthread_cond_broadcast(&creq->cond); + + pthread_mutex_unlock(&creq->lock); +} diff --git a/src/lib/cdap_req.h b/src/lib/cdap_req.h index 592d26a0..648ebc75 100644 --- a/src/lib/cdap_req.h +++ b/src/lib/cdap_req.h @@ -70,6 +70,6 @@ void cdap_req_respond(struct cdap_req * creq, int response, buffer_t data); -enum creq_state cdap_req_get_state(struct cdap_req * creq); +void cdap_req_cancel(struct cdap_req * creq); #endif /* OUROBOROS_CDAP_REQ_H */ |