summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-03-21 14:25:51 +0000
committerSander Vrijders <sander.vrijders@ugent.be>2017-03-21 14:25:51 +0000
commitd4e80d41197b75d2c351659c7e8d4546270e677d (patch)
tree75f499a09782dd03b9d61e69166b659f9d09f698 /src/lib
parent5a001d5a386af24ee25734e9195f4eb1641ad38c (diff)
parent0c8d8e419f7c9052d88bb9765bf43b01187977d0 (diff)
downloadouroboros-d4e80d41197b75d2c351659c7e8d4546270e677d.tar.gz
ouroboros-d4e80d41197b75d2c351659c7e8d4546270e677d.zip
Merged in dstaesse/ouroboros/be-lib-flowset (pull request #405)
lib: Add queued SDUs when adding fd to flow_set
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/dev.c6
-rw-r--r--src/lib/shm_rbuff.c20
2 files changed, 26 insertions, 0 deletions
diff --git a/src/lib/dev.c b/src/lib/dev.c
index 9ddc5b84..bd706dc8 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -1029,6 +1029,8 @@ int flow_set_add(struct flow_set * set,
int fd)
{
int ret;
+ size_t sdus;
+ size_t i;
if (set == NULL)
return -EINVAL;
@@ -1038,6 +1040,10 @@ int flow_set_add(struct flow_set * set,
ret = shm_flow_set_add(ai.fqset, set->idx, ai.flows[fd].port_id);
+ sdus = shm_rbuff_queued(ai.flows[fd].rx_rb);
+ for (i = 0; i < sdus; i++)
+ shm_flow_set_notify(ai.fqset, ai.flows[fd].port_id);
+
pthread_rwlock_unlock(&ai.flows_lock);
pthread_rwlock_unlock(&ai.data_lock);
diff --git a/src/lib/shm_rbuff.c b/src/lib/shm_rbuff.c
index a206a019..b8db7c19 100644
--- a/src/lib/shm_rbuff.c
+++ b/src/lib/shm_rbuff.c
@@ -384,3 +384,23 @@ void shm_rbuff_fini(struct shm_rbuff * rb)
#endif
pthread_cleanup_pop(true);
}
+
+size_t shm_rbuff_queued(struct shm_rbuff * rb)
+{
+ size_t ret;
+
+ assert(rb);
+
+#ifdef __APPLE__
+ pthread_mutex_lock(rb->lock);
+#else
+ if (pthread_mutex_lock(rb->lock) == EOWNERDEAD)
+ pthread_mutex_consistent(rb->lock);
+#endif
+
+ ret = shm_rbuff_used(rb);
+
+ pthread_mutex_unlock(rb->lock);
+
+ return ret;
+}