From 0a0c244b9939059b86d304dd127763fed7d10af4 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Wed, 22 Dec 2021 12:14:21 +0100 Subject: lib: Ease lock in timerwheel It was taking a write lock when a read lock was sufficient. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- CMakeLists.txt | 2 +- src/lib/timerwheel.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e49074d..27fe03ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ include(GNUInstallDirs) set(PACKAGE_VERSION_MAJOR 0) set(PACKAGE_VERSION_MINOR 18) -set(PACKAGE_VERSION_PATCH 3) +set(PACKAGE_VERSION_PATCH 4) set(PACKAGE_NAME "${CMAKE_PROJECT_NAME}") set(PACKAGE_DESCRIPTION "The Ouroboros prototype") diff --git a/src/lib/timerwheel.c b/src/lib/timerwheel.c index 3c1a44b4..487dcd0e 100644 --- a/src/lib/timerwheel.c +++ b/src/lib/timerwheel.c @@ -189,7 +189,7 @@ static void timerwheel_move(void) || f->flow_id != r->flow_id) goto cleanup; - pthread_rwlock_wrlock(&r->frcti->lock); + pthread_rwlock_rdlock(&r->frcti->lock); snd_lwe = snd_cr->lwe; rcv_lwe = rcv_cr->lwe; @@ -198,7 +198,7 @@ static void timerwheel_move(void) pthread_rwlock_unlock(&r->frcti->lock); /* Has been ack'd, remove. */ - if ((int) (r->seqno - snd_lwe) < 0) + if (before(r->seqno, snd_lwe)) goto cleanup; /* Check for r-timer expiry. */ -- cgit v1.2.3