summaryrefslogtreecommitdiff
path: root/src/lib/shm_du_map.c
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2016-07-05 19:11:26 +0200
committerSander Vrijders <sander.vrijders@intec.ugent.be>2016-07-05 19:11:26 +0200
commit6c799af1b4cf86a32979d98034c560fb976a9caf (patch)
treef9072634e81bc152c0ca52b927ab9984a845e0e8 /src/lib/shm_du_map.c
parentdb96f7d488681be47abfeec6c636fd4159a37660 (diff)
parentbc9c60382b226e5a75a11a99364b9b799dc2b0c2 (diff)
downloadouroboros-6c799af1b4cf86a32979d98034c560fb976a9caf.tar.gz
ouroboros-6c799af1b4cf86a32979d98034c560fb976a9caf.zip
Merged in dstaesse/ouroboros/be-pid (pull request #157)
lib: Change invalid pid to -1
Diffstat (limited to 'src/lib/shm_du_map.c')
-rw-r--r--src/lib/shm_du_map.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/lib/shm_du_map.c b/src/lib/shm_du_map.c
index cf0bad19..6289857f 100644
--- a/src/lib/shm_du_map.c
+++ b/src/lib/shm_du_map.c
@@ -89,12 +89,12 @@ static void garbage_collect(struct shm_du_map * dum)
{
#ifdef SHM_DU_MAP_MULTI_BLOCK
struct shm_du_buff * sdb;
- while ((sdb = get_tail_ptr(dum))->dst_api == 0 &&
+ while ((sdb = get_tail_ptr(dum))->dst_api == -1 &&
!shm_map_empty(dum))
*dum->ptr_tail = (*dum->ptr_tail + sdb->blocks)
& (SHM_BLOCKS_IN_MAP - 1);
#else
- while (get_tail_ptr(dum)->dst_api == 0 &&
+ while (get_tail_ptr(dum)->dst_api == -1 &&
!shm_map_empty(dum))
*dum->ptr_tail =
(*dum->ptr_tail + 1) & (SHM_BLOCKS_IN_MAP - 1);
@@ -110,7 +110,7 @@ static void clean_sdus(struct shm_du_map * dum, pid_t api)
while (idx != *dum->ptr_head) {
buf = idx_to_du_buff_ptr(dum, idx);
if (buf->dst_api == api)
- buf->dst_api = 0;
+ buf->dst_api = -1;
#ifdef SHM_DU_MAP_MULTI_BLOCK
idx = (idx + buf->blocks) & (SHM_BLOCKS_IN_MAP - 1);
#else
@@ -271,7 +271,7 @@ struct shm_du_map * shm_du_map_open()
pid_t shm_du_map_owner(struct shm_du_map * dum)
{
if (dum == NULL)
- return 0;
+ return -1;
return *dum->api;
}
@@ -444,7 +444,7 @@ ssize_t shm_du_map_write(struct shm_du_map * dum,
sdb = get_head_ptr(dum);
sdb->size = 0;
sdb->blocks = padblocks;
- sdb->dst_api = 0;
+ sdb->dst_api = -1;
sdb->du_head = 0;
sdb->du_tail = 0;
@@ -518,7 +518,7 @@ int shm_du_map_remove(struct shm_du_map * dum, ssize_t idx)
return -1;
}
- idx_to_du_buff_ptr(dum, idx)->dst_api = 0;
+ idx_to_du_buff_ptr(dum, idx)->dst_api = -1;
if (idx != *dum->ptr_tail) {
pthread_mutex_unlock(dum->shm_mutex);