summaryrefslogtreecommitdiff
path: root/src/lib/shm_ap_rbuff.c
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2016-05-14 21:10:08 +0200
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2016-05-14 21:10:08 +0200
commite82a5c416673e1eb2fbafb1deaaa8ac07971215e (patch)
tree57ace5cb356ad7a764670b594912cc310e140bdf /src/lib/shm_ap_rbuff.c
parentaf4097f51b7bd4f37212c2d49f0596779d79c36e (diff)
downloadouroboros-e82a5c416673e1eb2fbafb1deaaa8ac07971215e.tar.gz
ouroboros-e82a5c416673e1eb2fbafb1deaaa8ac07971215e.zip
lib: dev.c: added locking
Locking is required for multi-threaded applications. Flows are locked separately. Read/Write locks are used for concurrent reads.
Diffstat (limited to 'src/lib/shm_ap_rbuff.c')
-rw-r--r--src/lib/shm_ap_rbuff.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/lib/shm_ap_rbuff.c b/src/lib/shm_ap_rbuff.c
index 6c04ccc5..da6f0e33 100644
--- a/src/lib/shm_ap_rbuff.c
+++ b/src/lib/shm_ap_rbuff.c
@@ -253,8 +253,10 @@ struct rb_entry * shm_ap_rbuff_read(struct shm_ap_rbuff * rb)
}
e = malloc(sizeof(*e));
- if (e == NULL)
+ if (e == NULL) {
+ pthread_mutex_unlock(rb->shm_mutex);
return NULL;
+ }
*e = *(rb->shm_base + *rb->ptr_tail);