diff options
author | dimitri staessens <dimitri.staessens@ugent.be> | 2017-03-29 11:21:48 +0000 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@ugent.be> | 2017-03-29 11:21:48 +0000 |
commit | 9097a5446c31b83ec224b3e1403a319b24025346 (patch) | |
tree | 7e5714b5be41b8ebda807fcca71d084dcf1b9234 /src/lib/dev.c | |
parent | 99b9bd5273e6f7bbbaf4973ef15977ac7056b02d (diff) | |
parent | 3896a4d3e8634470557ea72ded70e7d9e33b7741 (diff) | |
download | ouroboros-9097a5446c31b83ec224b3e1403a319b24025346.tar.gz ouroboros-9097a5446c31b83ec224b3e1403a319b24025346.zip |
Merged in dstaesse/ouroboros/be-lib-fix (pull request #430)
lib: Fix locks in dev.c
Diffstat (limited to 'src/lib/dev.c')
-rw-r--r-- | src/lib/dev.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/lib/dev.c b/src/lib/dev.c index bd706dc8..79797b92 100644 --- a/src/lib/dev.c +++ b/src/lib/dev.c @@ -1394,6 +1394,7 @@ int ipcp_flow_read(int fd, { ssize_t idx = -1; int port_id = -1; + struct shm_rbuff * rb; pthread_rwlock_rdlock(&ai.data_lock); pthread_rwlock_rdlock(&ai.flows_lock); @@ -1404,22 +1405,19 @@ int ipcp_flow_read(int fd, return -ENOTALLOC; } + rb = ai.flows[fd].rx_rb; + pthread_rwlock_unlock(&ai.flows_lock); pthread_rwlock_unlock(&ai.data_lock); - idx = shm_rbuff_read(ai.flows[fd].rx_rb); - if (idx < 0) { - pthread_rwlock_rdlock(&ai.data_lock); - pthread_rwlock_rdlock(&ai.flows_lock); + idx = shm_rbuff_read(rb); + if (idx < 0) return idx; - } pthread_rwlock_rdlock(&ai.data_lock); - pthread_rwlock_rdlock(&ai.flows_lock); *sdb = shm_rdrbuff_get(ai.rdrb, idx); - pthread_rwlock_unlock(&ai.flows_lock); pthread_rwlock_unlock(&ai.data_lock); return 0; |