summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2016-05-17 22:44:19 +0200
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2016-05-17 22:44:19 +0200
commit4d348ef99bb3e3927be315ef1bdd1ae827c9a28c (patch)
treea9c9a626da1d143edd45a04cbbeb215debeebb1d /src
parentf9f95b5e8ebf55109adc1f8ec242051408dc8811 (diff)
parentac4c044e13f813bcf2c765fcb88ab473c839692d (diff)
downloadouroboros-4d348ef99bb3e3927be315ef1bdd1ae827c9a28c.tar.gz
ouroboros-4d348ef99bb3e3927be315ef1bdd1ae827c9a28c.zip
Merged in sandervrijders/ouroboros/be (pull request #99)
lib: Add missing check upon garbage collection
Diffstat (limited to 'src')
-rw-r--r--src/lib/shm_du_map.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lib/shm_du_map.c b/src/lib/shm_du_map.c
index 1bd89744..e207c05e 100644
--- a/src/lib/shm_du_map.c
+++ b/src/lib/shm_du_map.c
@@ -334,7 +334,6 @@ int shm_release_du_buff(struct shm_du_map * dum, ssize_t idx)
long sz;
long blocks = 0;
-
if (idx > SHM_BLOCKS_IN_MAP)
return -1;
@@ -352,7 +351,8 @@ int shm_release_du_buff(struct shm_du_map * dum, ssize_t idx)
return 0;
}
- while (get_tail_ptr(dum)->garbage == 1) {
+ while (get_tail_ptr(dum)->garbage == 1 &&
+ *dum->ptr_tail != *dum->ptr_head) {
sz = get_tail_ptr(dum)->size;
while (sz + (long) sizeof(struct shm_du_buff) > 0) {
sz -= SHM_DU_BUFF_BLOCK_SIZE;
@@ -361,6 +361,7 @@ int shm_release_du_buff(struct shm_du_map * dum, ssize_t idx)
*(dum->ptr_tail) =
(*dum->ptr_tail + blocks) & (SHM_BLOCKS_IN_MAP - 1);
+
blocks = 0;
}