summaryrefslogtreecommitdiff
path: root/src/lib/dev.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri.staessens@ugent.be>2019-04-06 13:34:17 +0200
committerSander Vrijders <sander@ouroboros.rocks>2019-04-06 13:40:52 +0200
commit3e446f29375c0908e8b68ad3a4fd0c5958538150 (patch)
tree323b8f4051567c4e552d622f55a06c224a78fd7a /src/lib/dev.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 <dimitri.staessens@ugent.be> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/lib/dev.c')
-rw-r--r--src/lib/dev.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/lib/dev.c b/src/lib/dev.c
index 6d5676af..ee7839c8 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -933,7 +933,11 @@ ssize_t flow_write(int fd,
pthread_rwlock_rdlock(&ai.lock);
- ret = shm_rbuff_write(flow->tx_rb, idx);
+ if (flags & FLOWFWNOBLOCK)
+ ret = shm_rbuff_write(flow->tx_rb, idx);
+ else
+ ret = shm_rbuff_write_b(flow->tx_rb, idx, abstime);
+
if (ret < 0)
shm_rdrbuff_remove(ai.rdrb, idx);
else
@@ -1444,9 +1448,11 @@ int ipcp_flow_write(int fd,
return -ENOMEM;
}
- ret = shm_rbuff_write(flow->tx_rb, idx);
+ ret = shm_rbuff_write_b(flow->tx_rb, idx, NULL);
if (ret == 0)
shm_flow_set_notify(flow->set, flow->flow_id, FLOW_PKT);
+ else
+ shm_rdrbuff_remove(ai.rdrb, idx);
pthread_rwlock_unlock(&ai.lock);
@@ -1544,10 +1550,11 @@ int local_flow_write(int fd,
pthread_rwlock_unlock(&ai.lock);
return -ENOTALLOC;
}
-
- ret = shm_rbuff_write(flow->tx_rb, idx);
+ ret = shm_rbuff_write_b(flow->tx_rb, idx, NULL);
if (ret == 0)
shm_flow_set_notify(flow->set, flow->flow_id, FLOW_PKT);
+ else
+ shm_rdrbuff_remove(ai.rdrb, idx);
pthread_rwlock_unlock(&ai.lock);