summaryrefslogtreecommitdiff
path: root/src/lib/shm_ap_rbuff.c
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2016-08-29 19:49:39 +0200
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2016-08-29 20:32:54 +0200
commit2cc89f6da424ab503af563e0cc92dda43b8f8432 (patch)
tree303d3d61717d4d3018b8025a9825ff799da01c08 /src/lib/shm_ap_rbuff.c
parentcaeefb4d96331d24b38e845c99d0517913a71671 (diff)
downloadouroboros-2cc89f6da424ab503af563e0cc92dda43b8f8432.tar.gz
ouroboros-2cc89f6da424ab503af563e0cc92dda43b8f8432.zip
lib: Refactor shm_du_map to shm_rdrbuff
The shm_du_map is renamed to shm_rdrbuff to reflect the Random Deletion Ringbuffer used in the implementation. The close_on_exit call is removed and SDUs are cleaned up by the application in the ap_fini() call. This required a non-blocking peek() operation in the shm_ap_rbuff. Some initial implementation for future support of qos cubes has been added to the shm_rdrbuff.
Diffstat (limited to 'src/lib/shm_ap_rbuff.c')
-rw-r--r--src/lib/shm_ap_rbuff.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/lib/shm_ap_rbuff.c b/src/lib/shm_ap_rbuff.c
index 4ca29636..f21b1e86 100644
--- a/src/lib/shm_ap_rbuff.c
+++ b/src/lib/shm_ap_rbuff.c
@@ -285,8 +285,32 @@ int shm_ap_rbuff_write(struct shm_ap_rbuff * rb, struct rb_entry * e)
return 0;
}
-int shm_ap_rbuff_peek(struct shm_ap_rbuff * rb,
- const struct timespec * timeout)
+int shm_ap_rbuff_peek_idx(struct shm_ap_rbuff * rb)
+{
+ int ret = 0;
+
+ if (rb == NULL)
+ return -EINVAL;
+
+ if (pthread_mutex_lock(rb->lock) == EOWNERDEAD) {
+ LOG_DBG("Recovering dead mutex.");
+ pthread_mutex_consistent(rb->lock);
+ }
+
+ if (shm_rbuff_empty(rb)) {
+ pthread_mutex_unlock(rb->lock);
+ return -1;
+ }
+
+ ret = (rb->shm_base + *rb->ptr_tail)->index;
+
+ pthread_mutex_unlock(rb->lock);
+
+ return ret;
+}
+
+int shm_ap_rbuff_peek_b(struct shm_ap_rbuff * rb,
+ const struct timespec * timeout)
{
struct timespec abstime;
int ret = 0;