diff options
author | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2017-01-24 18:02:04 +0100 |
---|---|---|
committer | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2017-01-24 18:18:53 +0100 |
commit | bd293f2cdb57ea966d86219d6f661194482a2705 (patch) | |
tree | 865c3a4ddaae033d499f4dfb96d55db602694751 /src/lib | |
parent | 317821ca093f7c22e0bf1a9bb15e17c3c501e498 (diff) | |
download | ouroboros-bd293f2cdb57ea966d86219d6f661194482a2705.tar.gz ouroboros-bd293f2cdb57ea966d86219d6f661194482a2705.zip |
lib: Fix reading from non-blocking flows
The -EAGAIN from a failed non-blocking flow read would trigger the
assertion. This snuck in somehow (we need some unit tests for dev.c).
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/dev.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/lib/dev.c b/src/lib/dev.c index c62fea40..eefb9b18 100644 --- a/src/lib/dev.c +++ b/src/lib/dev.c @@ -919,13 +919,12 @@ ssize_t flow_read(int fd, void * buf, size_t count) pthread_rwlock_rdlock(&ai.data_lock); } - if (idx == -ETIMEDOUT) { + if (idx < 0) { + assert(idx == -EAGAIN || idx == -ETIMEDOUT); pthread_rwlock_unlock(&ai.data_lock); - return -ETIMEDOUT; + return idx; } - assert(idx >= 0); - n = shm_rdrbuff_read(&sdu, ai.rdrb, idx); if (n < 0) { pthread_rwlock_unlock(&ai.data_lock); |