diff options
author | Dimitri Staessens <[email protected]> | 2019-04-06 13:34:17 +0200 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2019-04-06 13:40:52 +0200 |
commit | 3e446f29375c0908e8b68ad3a4fd0c5958538150 (patch) | |
tree | 323b8f4051567c4e552d622f55a06c224a78fd7a /src/lib/dev.c | |
parent | 7039fd62a5863741adb757665696a67a8228db40 (diff) | |
download | ouroboros-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/dev.c')
-rw-r--r-- | src/lib/dev.c | 15 |
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); |