diff --git a/lib/thread/thread.c b/lib/thread/thread.c index 65ddd5bde..71c483154 100644 --- a/lib/thread/thread.c +++ b/lib/thread/thread.c @@ -512,10 +512,6 @@ spdk_thread_poll(struct spdk_thread *thread, uint32_t max_msgs, uint64_t now) active_pollers_head, tailq, tmp) { int poller_rc; - if (thread->exit) { - break; - } - if (poller->state == SPDK_POLLER_STATE_UNREGISTERED) { TAILQ_REMOVE(&thread->active_pollers, poller, tailq); free(poller); @@ -551,10 +547,6 @@ spdk_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 (thread->exit) { - break; - } - if (poller->state == SPDK_POLLER_STATE_UNREGISTERED) { TAILQ_REMOVE(&thread->timed_pollers, poller, tailq); free(poller); @@ -778,6 +770,11 @@ spdk_poller_register(spdk_poller_fn fn, return NULL; } + if (spdk_unlikely(thread->exit)) { + SPDK_ERRLOG("thread %s is marked as exited\n", thread->name); + return NULL; + } + poller = calloc(1, sizeof(*poller)); if (poller == NULL) { SPDK_ERRLOG("Poller memory allocation failed\n");