From 57e8b5f8b933e6d405d6d81127da5813d7760371 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sat, 26 Sep 2020 16:36:20 +0200 Subject: lib: Fix locking for FRCT Flows should be locked when moving the timerwheel. For frcti_snd, a rdlock is enough. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/lib/dev.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/dev.c b/src/lib/dev.c index 8d7d7934..5cf23639 100644 --- a/src/lib/dev.c +++ b/src/lib/dev.c @@ -1067,7 +1067,7 @@ ssize_t flow_write(int fd, memcpy(ptr, buf, count); - pthread_rwlock_wrlock(&ai.lock); + pthread_rwlock_rdlock(&ai.lock); if (frcti_snd(flow->frcti, sdb) < 0) { pthread_rwlock_unlock(&ai.lock); @@ -1333,7 +1333,7 @@ void fset_del(struct flow_set * set, if (set == NULL || fd < 0 || fd > SYS_MAX_FLOWS) return; - pthread_rwlock_wrlock(&ai.lock); + pthread_rwlock_rdlock(&ai.lock); if (ai.flows[fd].flow_id >= 0) shm_flow_set_del(ai.fqset, set->idx, ai.flows[fd].flow_id); @@ -1433,7 +1433,9 @@ ssize_t fevent(struct flow_set * set, } ret = 0; ts_add(t, &tic, t); + pthread_rwlock_rdlock(&ai.lock); timerwheel_move(); + pthread_rwlock_unlock(&ai.lock); continue; } -- cgit v1.2.3