diff options
author | Dimitri Staessens <dimitri@ouroboros.rocks> | 2022-03-26 20:28:56 +0100 |
---|---|---|
committer | Sander Vrijders <sander@ouroboros.rocks> | 2022-03-30 15:05:05 +0200 |
commit | 56654f2cd1813d87d32695f126939bbfaad52385 (patch) | |
tree | 548a48888869e553e95e6e1ce37dc0cfaed0ab56 /src/lib/shm_rbuff_ll.c | |
parent | 643c285c20abab5dadaa5c1929d978b725911b5d (diff) | |
download | ouroboros-56654f2cd1813d87d32695f126939bbfaad52385.tar.gz ouroboros-56654f2cd1813d87d32695f126939bbfaad52385.zip |
lib: Add rbuff support for FLOWPEER state
This allows setting the FLOWPEER state on a flow to signal a peer is
unresponsive.
Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/lib/shm_rbuff_ll.c')
-rw-r--r-- | src/lib/shm_rbuff_ll.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/lib/shm_rbuff_ll.c b/src/lib/shm_rbuff_ll.c index 880d81dc..2eed9b74 100644 --- a/src/lib/shm_rbuff_ll.c +++ b/src/lib/shm_rbuff_ll.c @@ -143,9 +143,15 @@ ssize_t shm_rbuff_read(struct shm_rbuff * rb) assert(rb); - if (shm_rbuff_empty(rb)) - return __sync_fetch_and_add(rb->acl, 0) & ACL_FLOWDOWN ? - -EFLOWDOWN : -EAGAIN; + if (shm_rbuff_empty(rb)) { + if (_sync_fetch_and_add(rb->acl, 0) & ACL_FLOWDOWN) + return -EFLOWDOWN; + + if (_sync_fetch_and_add(rb->acl, 0) & ACL_FLOWPEER) + return -EFLOWPEER; + + return -EAGAIN; + } ntail = RB_TAIL; |