summaryrefslogtreecommitdiff
path: root/src/lib/shm_rbuff.c
diff options
context:
space:
mode:
authorDimitri Staessens <[email protected]>2019-04-06 13:34:17 +0200
committerSander Vrijders <[email protected]>2019-04-06 13:40:52 +0200
commit3e446f29375c0908e8b68ad3a4fd0c5958538150 (patch)
tree323b8f4051567c4e552d622f55a06c224a78fd7a /src/lib/shm_rbuff.c
parent7039fd62a5863741adb757665696a67a8228db40 (diff)
downloadouroboros-3e446f29375c0908e8b68ad3a4fd0c5958538150.tar.gz
ouroboros-3e446f29375c0908e8b68ad3a4fd0c5958538150.zip
lib: Set independent size for rbuff
This allows setting the size of the rbuffs in a system independently of the main packet buffer using SHM_RBUFF_SIZE. The benefit of setting a smaller rbuff size is that a single process can't fully occupy the main packet buffer. Signed-off-by: Dimitri Staessens <[email protected]> Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src/lib/shm_rbuff.c')
-rw-r--r--src/lib/shm_rbuff.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/lib/shm_rbuff.c b/src/lib/shm_rbuff.c
index f7f383fc..ebae9702 100644
--- a/src/lib/shm_rbuff.c
+++ b/src/lib/shm_rbuff.c
@@ -45,14 +45,14 @@
#define FN_MAX_CHARS 255
-#define SHM_RB_FILE_SIZE ((SHM_BUFFER_SIZE) * sizeof(ssize_t) \
+#define SHM_RB_FILE_SIZE ((SHM_RBUFF_SIZE) * sizeof(ssize_t) \
+ 3 * sizeof(size_t) \
+ sizeof(pthread_mutex_t) \
+ 2 * sizeof (pthread_cond_t))
-#define shm_rbuff_used(rb) ((*rb->head + (SHM_BUFFER_SIZE) - *rb->tail) \
- & ((SHM_BUFFER_SIZE) - 1))
-#define shm_rbuff_free(rb) (shm_rbuff_used(rb) + 1 < (SHM_BUFFER_SIZE))
+#define shm_rbuff_used(rb) ((*rb->head + (SHM_RBUFF_SIZE) - *rb->tail) \
+ & ((SHM_RBUFF_SIZE) - 1))
+#define shm_rbuff_free(rb) (shm_rbuff_used(rb) + 1 < (SHM_RBUFF_SIZE))
#define shm_rbuff_empty(rb) (*rb->head == *rb->tail)
#define head_el_ptr(rb) (rb->shm_base + *rb->head)
#define tail_el_ptr(rb) (rb->shm_base + *rb->tail)
@@ -109,7 +109,7 @@ struct shm_rbuff * rbuff_create(pid_t pid,
close(fd);
rb->shm_base = shm_base;
- rb->head = (size_t *) (rb->shm_base + (SHM_BUFFER_SIZE));
+ rb->head = (size_t *) (rb->shm_base + (SHM_RBUFF_SIZE));
rb->tail = rb->head + 1;
rb->acl = rb->tail + 1;
rb->lock = (pthread_mutex_t *) (rb->acl + 1);