diff options
author | Sander Vrijders <[email protected]> | 2016-05-20 17:49:26 +0200 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2016-05-20 17:49:26 +0200 |
commit | a5df21fd010d98e8f9f51ccd2aeae03a726e94b5 (patch) | |
tree | 301199d037c9c74bd683a2937fb49fc12e692cf6 /src/lib/dev.c | |
parent | 303034090a9e8da6b096c1e61553dacaf359f187 (diff) | |
parent | d32d7eae209f3ee09a690cc9adb6ea277e0d17aa (diff) | |
download | ouroboros-a5df21fd010d98e8f9f51ccd2aeae03a726e94b5.tar.gz ouroboros-a5df21fd010d98e8f9f51ccd2aeae03a726e94b5.zip |
Merged in dstaesse/ouroboros/be-fp (pull request #101)
lib: allow parallel connections
Diffstat (limited to 'src/lib/dev.c')
-rw-r--r-- | src/lib/dev.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/lib/dev.c b/src/lib/dev.c index c365a17b..fab37bbf 100644 --- a/src/lib/dev.c +++ b/src/lib/dev.c @@ -588,18 +588,21 @@ ssize_t flow_read(int fd, void * buf, size_t count) rw_lock_rdlock(&_ap_instance->flows_lock); if (_ap_instance->flows[fd].oflags & FLOW_O_NONBLOCK) { - e = shm_ap_rbuff_read(_ap_instance->rb); - } else { - - /* FIXME: this will throw away packets for other fd's */ - while (e == NULL || - e->port_id != _ap_instance->flows[fd].port_id) { - e = shm_ap_rbuff_read(_ap_instance->rb); + if (shm_ap_rbuff_peek(_ap_instance->rb) + != _ap_instance->flows[fd].port_id) { + rw_lock_unlock(&_ap_instance->flows_lock); + rw_lock_unlock(&_ap_instance->data_lock); + return -1; } + } else { /* block */ + while (shm_ap_rbuff_peek(_ap_instance->rb) + != _ap_instance->flows[fd].port_id) + ; } rw_lock_unlock(&_ap_instance->flows_lock); + e = shm_ap_rbuff_read(_ap_instance->rb); if (e == NULL) { rw_lock_unlock(&_ap_instance->data_lock); return -1; |