From 84ec9989763f0f5367e6c12be3f23800e0d4e28a Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Mon, 26 Apr 2021 18:59:33 +0900 Subject: [PATCH] thread: Check if timed poller is expired first in iteration of thread_poll() There will be no issue even if time poller is unregistered or paused after it is expired. The iteration is stopped anyway after the head poller is found not to be expired. Signed-off-by: Shuhei Matsumoto Change-Id: I2b394b8b517930a6630dd31f59fcaea12eb80572 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7662 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Jim Harris Reviewed-by: Konrad Sztyber Reviewed-by: Aleksey Marchuk --- lib/thread/thread.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/thread/thread.c b/lib/thread/thread.c index aa0c31983..d91cffa84 100644 --- a/lib/thread/thread.c +++ b/lib/thread/thread.c @@ -669,6 +669,10 @@ thread_poll(struct spdk_thread *thread, uint32_t max_msgs, uint64_t now) TAILQ_FOREACH_SAFE(poller, &thread->timed_pollers, tailq, tmp) { int timer_rc = 0; + if (now < poller->next_run_tick) { + break; + } + if (poller->state == SPDK_POLLER_STATE_UNREGISTERED) { TAILQ_REMOVE(&thread->timed_pollers, poller, tailq); free(poller); @@ -680,10 +684,6 @@ thread_poll(struct spdk_thread *thread, uint32_t max_msgs, uint64_t now) continue; } - if (now < poller->next_run_tick) { - break; - } - poller->state = SPDK_POLLER_STATE_RUNNING; timer_rc = poller->fn(poller->arg);