diff options
Diffstat (limited to 'src/lib/shm_rbuff.c')
-rw-r--r-- | src/lib/shm_rbuff.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/lib/shm_rbuff.c b/src/lib/shm_rbuff.c index 0d0795aa..b8db7c19 100644 --- a/src/lib/shm_rbuff.c +++ b/src/lib/shm_rbuff.c @@ -3,7 +3,8 @@ * * Ring buffer for incoming SDUs * - * Dimitri Staessens <dimitri.staessens@intec.ugent.be> + * Dimitri Staessens <dimitri.staessens@ugent.be> + * Sander Vrijders <sander.vrijders@ugent.be> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -383,3 +384,23 @@ void shm_rbuff_fini(struct shm_rbuff * rb) #endif pthread_cleanup_pop(true); } + +size_t shm_rbuff_queued(struct shm_rbuff * rb) +{ + size_t ret; + + assert(rb); + +#ifdef __APPLE__ + pthread_mutex_lock(rb->lock); +#else + if (pthread_mutex_lock(rb->lock) == EOWNERDEAD) + pthread_mutex_consistent(rb->lock); +#endif + + ret = shm_rbuff_used(rb); + + pthread_mutex_unlock(rb->lock); + + return ret; +} |