diff options
Diffstat (limited to 'src/lib/timerwheel.c')
-rw-r--r-- | src/lib/timerwheel.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/lib/timerwheel.c b/src/lib/timerwheel.c index cd3074cb..a9f3c72a 100644 --- a/src/lib/timerwheel.c +++ b/src/lib/timerwheel.c @@ -65,6 +65,8 @@ struct { size_t prv_rxm; /* Last processed rxm slot at lvl 0. */ size_t prv_ack; /* Last processed ack slot. */ pthread_mutex_t lock; + + bool in_use; } rw; static void timerwheel_fini(void) @@ -140,6 +142,9 @@ static void timerwheel_move(void) size_t i; size_t j; + if (!__sync_bool_compare_and_swap(&rw.in_use, true, true)) + return; + pthread_mutex_lock(&rw.lock); pthread_cleanup_push((void (*) (void *)) pthread_mutex_unlock, @@ -373,6 +378,8 @@ static int timerwheel_rxm(struct frcti * frcti, #endif pthread_mutex_unlock(&rw.lock); + __sync_bool_compare_and_swap(&rw.in_use, false, true); + return 0; } @@ -416,5 +423,7 @@ static int timerwheel_ack(int fd, pthread_mutex_unlock(&rw.lock); + __sync_bool_compare_and_swap(&rw.in_use, false, true); + return 0; } |