From bd293f2cdb57ea966d86219d6f661194482a2705 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Tue, 24 Jan 2017 18:02:04 +0100 Subject: 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). --- src/lib/dev.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/lib') 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); -- cgit v1.2.3