From c9fb31c7ebadc076b7c3bfd9dbe1c492c6ef7172 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Fri, 3 Mar 2017 15:31:42 +0100 Subject: Change email addresses to ugent.be Our mailserver was migrated from intec.ugent.be to the central ugent.be emailserver. This PR updates the header files to reflect this change as well. Some header files were also homogenized if the parameters within the functions were badly aligned. --- src/lib/shm_rbuff.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/lib/shm_rbuff.c') diff --git a/src/lib/shm_rbuff.c b/src/lib/shm_rbuff.c index 0d0795aa..a206a019 100644 --- a/src/lib/shm_rbuff.c +++ b/src/lib/shm_rbuff.c @@ -3,7 +3,8 @@ * * Ring buffer for incoming SDUs * - * Dimitri Staessens + * Dimitri Staessens + * Sander Vrijders * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License -- cgit v1.2.3 From 0c8d8e419f7c9052d88bb9765bf43b01187977d0 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Tue, 21 Mar 2017 15:21:52 +0100 Subject: lib: Add queued SDUs when adding fd to flow_set This solves some race conditions where packets arrive on a flow before it is added to a flow_set. --- include/ouroboros/shm_rbuff.h | 2 ++ src/lib/dev.c | 6 ++++++ src/lib/shm_rbuff.c | 20 ++++++++++++++++++++ 3 files changed, 28 insertions(+) (limited to 'src/lib/shm_rbuff.c') diff --git a/include/ouroboros/shm_rbuff.h b/include/ouroboros/shm_rbuff.h index f31dab63..8471f47f 100644 --- a/include/ouroboros/shm_rbuff.h +++ b/include/ouroboros/shm_rbuff.h @@ -53,4 +53,6 @@ ssize_t shm_rbuff_read(struct shm_rbuff * rb); ssize_t shm_rbuff_read_b(struct shm_rbuff * rb, const struct timespec * timeout); +size_t shm_rbuff_queued(struct shm_rbuff * rb); + #endif /* OUROBOROS_SHM_RBUFF_H */ 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; +} -- cgit v1.2.3