summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2016-05-17 21:40:36 +0200
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2016-05-17 21:40:36 +0200
commitf9f95b5e8ebf55109adc1f8ec242051408dc8811 (patch)
tree1f926effe772c1ef49a1fb2109e13171a4a14e28 /src/lib
parent950bc6a4c195e8751ada64c7c9a3f842adbc23c5 (diff)
parent81e32e5d19bdc0dabd7473a31ddb0d6f1c95e18e (diff)
downloadouroboros-f9f95b5e8ebf55109adc1f8ec242051408dc8811.tar.gz
ouroboros-f9f95b5e8ebf55109adc1f8ec242051408dc8811.zip
Merged in sandervrijders/ouroboros/be (pull request #98)
lib: Fixed incorrect comparison
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/shm_du_map.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/lib/shm_du_map.c b/src/lib/shm_du_map.c
index a7ec5ac9..1bd89744 100644
--- a/src/lib/shm_du_map.c
+++ b/src/lib/shm_du_map.c
@@ -294,7 +294,8 @@ ssize_t shm_create_du_buff(struct shm_du_map * dum,
--blocks;
}
- index = (*dum->ptr_head - 1) & (SHM_BLOCKS_IN_MAP - 1);
+ index = (*dum->ptr_head - 1 + SHM_BLOCKS_IN_MAP)
+ & (SHM_BLOCKS_IN_MAP - 1);
pthread_mutex_unlock(dum->shm_mutex);
@@ -353,14 +354,14 @@ int shm_release_du_buff(struct shm_du_map * dum, ssize_t idx)
while (get_tail_ptr(dum)->garbage == 1) {
sz = get_tail_ptr(dum)->size;
-
- while (sz + (long) sizeof (struct shm_du_buff) > 0) {
+ while (sz + (long) sizeof(struct shm_du_buff) > 0) {
sz -= SHM_DU_BUFF_BLOCK_SIZE;
++blocks;
}
*(dum->ptr_tail) =
(*dum->ptr_tail + blocks) & (SHM_BLOCKS_IN_MAP - 1);
+ blocks = 0;
}
pthread_mutex_unlock(dum->shm_mutex);