summaryrefslogtreecommitdiff
path: root/src/lib/dev.c
diff options
context:
space:
mode:
authordimitri staessens <[email protected]>2017-04-01 10:04:59 +0000
committerSander Vrijders <[email protected]>2017-04-01 10:04:59 +0000
commitd9f3619d791fef7d79127556304a4aa4f1cda50a (patch)
treeefd58bca3a7c0d2302bbc9c9eaffa1d0dc95ad89 /src/lib/dev.c
parentd9d3d3010511a1893e5fffdfbc5378db59233a1e (diff)
parentd426058a82137d3186a245b0548a262fbd35761b (diff)
downloadouroboros-d9f3619d791fef7d79127556304a4aa4f1cda50a.tar.gz
ouroboros-d9f3619d791fef7d79127556304a4aa4f1cda50a.zip
Merged in dstaesse/ouroboros/be-fixes (pull request #447)
Be fixes
Diffstat (limited to 'src/lib/dev.c')
-rw-r--r--src/lib/dev.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/lib/dev.c b/src/lib/dev.c
index e19083c3..5acbada2 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -555,6 +555,7 @@ int flow_alloc(const char * dst_name,
ai.flows[fd].api = recv_msg->api;
ai.flows[fd].cube = recv_msg->qoscube;
+ ai.ports[recv_msg->port_id].fd = fd;
ai.ports[recv_msg->port_id].state = PORT_ID_ASSIGNED;
pthread_rwlock_unlock(&ai.flows_lock);
@@ -921,7 +922,7 @@ struct fqueue * fqueue_create()
if (fq == NULL)
return NULL;
- memset(fq->fqueue, -1, SHM_BUFFER_SIZE);
+ memset(fq->fqueue, -1, (SHM_BUFFER_SIZE) * sizeof(*fq->fqueue));
fq->fqsize = 0;
fq->next = 0;
@@ -1021,11 +1022,8 @@ int fqueue_next(struct fqueue * fq)
if (fq == NULL)
return -EINVAL;
- if (fq->next == fq->fqsize) {
- fq->fqsize = 0;
- fq->next = 0;
+ if (fq->fqsize == 0)
return -EPERM;
- }
pthread_rwlock_rdlock(&ai.data_lock);
pthread_rwlock_rdlock(&ai.flows_lock);
@@ -1035,6 +1033,11 @@ int fqueue_next(struct fqueue * fq)
pthread_rwlock_unlock(&ai.flows_lock);
pthread_rwlock_unlock(&ai.data_lock);
+ if (fq->next == fq->fqsize) {
+ fq->fqsize = 0;
+ fq->next = 0;
+ }
+
return fd;
}
@@ -1319,6 +1322,9 @@ int ipcp_flow_read(int fd,
int port_id = -1;
struct shm_rbuff * rb;
+ assert(fd >=0);
+ assert(sdb);
+
pthread_rwlock_rdlock(&ai.data_lock);
pthread_rwlock_rdlock(&ai.flows_lock);
@@ -1427,6 +1433,8 @@ ssize_t local_flow_read(int fd)
{
ssize_t ret;
+ assert(fd >= 0);
+
pthread_rwlock_rdlock(&ai.data_lock);
pthread_rwlock_rdlock(&ai.flows_lock);