summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Staessens <[email protected]>2020-09-26 16:36:20 +0200
committerSander Vrijders <[email protected]>2020-09-26 17:00:49 +0200
commit57e8b5f8b933e6d405d6d81127da5813d7760371 (patch)
tree847ff7e45fc8a379d6eacddd82d6718b2e4b3180
parent74c4155dc472651be9c40528657bdf35bfffd87c (diff)
downloadouroboros-57e8b5f8b933e6d405d6d81127da5813d7760371.tar.gz
ouroboros-57e8b5f8b933e6d405d6d81127da5813d7760371.zip
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 <[email protected]> Signed-off-by: Sander Vrijders <[email protected]>
-rw-r--r--src/lib/dev.c6
1 files 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;
}