summaryrefslogtreecommitdiff
path: root/src/lib/shm_ap_rbuff.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/shm_ap_rbuff.c')
-rw-r--r--src/lib/shm_ap_rbuff.c16
1 files changed, 1 insertions, 15 deletions
diff --git a/src/lib/shm_ap_rbuff.c b/src/lib/shm_ap_rbuff.c
index 56555533..e9c51533 100644
--- a/src/lib/shm_ap_rbuff.c
+++ b/src/lib/shm_ap_rbuff.c
@@ -52,9 +52,6 @@
#define shm_rbuff_empty(rb) (*rb->ptr_head == *rb->ptr_tail)
#define head_el_ptr(rb) (rb->shm_base + *rb->ptr_head)
#define tail_el_ptr(rb) (rb->shm_base + *rb->ptr_tail)
-#define clean_sdus(rb) \
- while (!shm_rbuff_empty(rb) && tail_el_ptr(rb)->port_id < 0) \
- *rb->ptr_tail = (*rb->ptr_tail + 1) & (SHM_BUFFER_SIZE -1); \
struct shm_ap_rbuff {
struct rb_entry * shm_base; /* start of entry */
@@ -173,6 +170,7 @@ struct shm_ap_rbuff * shm_ap_rbuff_open(pid_t api)
shm_fd = shm_open(fn, O_RDWR, 0666);
if (shm_fd == -1) {
LOG_DBG("%d failed opening shared memory %s.", getpid(), fn);
+ free(rb);
return NULL;
}
@@ -315,8 +313,6 @@ int shm_ap_rbuff_peek(struct shm_ap_rbuff * rb,
pthread_mutex_consistent(rb->lock);
}
- clean_sdus(rb);
-
while (shm_rbuff_empty(rb)) {
if (timeout != NULL)
ret = pthread_cond_timedwait(rb->add,
@@ -325,8 +321,6 @@ int shm_ap_rbuff_peek(struct shm_ap_rbuff * rb,
else
ret = pthread_cond_wait(rb->add, rb->lock);
- clean_sdus(rb);
-
if (ret == EOWNERDEAD) {
LOG_DBG("Recovering dead mutex.");
pthread_mutex_consistent(rb->lock);
@@ -360,8 +354,6 @@ struct rb_entry * shm_ap_rbuff_read(struct shm_ap_rbuff * rb)
pthread_mutex_consistent(rb->lock);
}
- clean_sdus(rb);
-
while (shm_rbuff_empty(rb))
if (pthread_cond_wait(rb->add, rb->lock) == EOWNERDEAD) {
LOG_DBG("Recovering dead mutex.");
@@ -392,8 +384,6 @@ ssize_t shm_ap_rbuff_read_port(struct shm_ap_rbuff * rb, int port_id)
pthread_mutex_consistent(rb->lock);
}
- clean_sdus(rb);
-
if (shm_rbuff_empty(rb) || tail_el_ptr(rb)->port_id != port_id) {
pthread_mutex_unlock(rb->lock);
return -1;
@@ -428,8 +418,6 @@ ssize_t shm_ap_rbuff_read_port_b(struct shm_ap_rbuff * rb,
ts_add(&abstime, timeout, &abstime);
}
- clean_sdus(rb);
-
pthread_cleanup_push((void(*)(void *))pthread_mutex_unlock,
(void *) rb->lock);
@@ -441,8 +429,6 @@ ssize_t shm_ap_rbuff_read_port_b(struct shm_ap_rbuff * rb,
else
ret = pthread_cond_wait(rb->del, rb->lock);
- clean_sdus(rb);
-
if (ret == EOWNERDEAD) {
LOG_DBG("Recovering dead mutex.");
pthread_mutex_consistent(rb->lock);