diff options
author | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2016-05-17 22:18:09 +0200 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2016-05-17 22:18:09 +0200 |
commit | 39c326d7cc333e88cc6a608853290132299fae0d (patch) | |
tree | a9c9a626da1d143edd45a04cbbeb215debeebb1d /src/lib/shm_du_map.c | |
parent | 81e32e5d19bdc0dabd7473a31ddb0d6f1c95e18e (diff) | |
download | ouroboros-39c326d7cc333e88cc6a608853290132299fae0d.tar.gz ouroboros-39c326d7cc333e88cc6a608853290132299fae0d.zip |
lib: Add missing check upon garbage collection
There was a check missing upon garbage collection. If the whole DU map
has been used once, all DUs will have their garbage bit set to
one. This meant that the garbage collector would keep moving the tail
indefinitely.
Diffstat (limited to 'src/lib/shm_du_map.c')
-rw-r--r-- | src/lib/shm_du_map.c | 5 |
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; } |