summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-03-31 20:38:15 +0200
committerdimitri staessens <dimitri.staessens@ugent.be>2017-04-01 14:25:39 +0200
commit8913ac0a36c068c012cd0be9591cfad63a1af44e (patch)
treef8fc2a422eba71604e86a2a4217ef95d6a7bdd6c /src/lib
parent014daf9684e85566cfcf44ec107c8cb792df3b14 (diff)
downloadouroboros-8913ac0a36c068c012cd0be9591cfad63a1af44e.tar.gz
ouroboros-8913ac0a36c068c012cd0be9591cfad63a1af44e.zip
lib: Fix missing assignment in flow_alloc
Diffstat (limited to 'src/lib')
-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);