lib/thread: account for busy work for unregistered timers
When a timed poller unregisters itself during execution, we were continuing the loop without updating the timer_rc. This would result in spdk_thread_poll() indicating that the poll execution was idle rather than busy. Note that the DEBUG print would have still been OK where it was, since the poller variable itself was valid, even though it had been freed. But it looked a bit awkward there, so I moved it right after we capture timer_rc. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: I0673261ecea0e49db97b008a83b60a35f995f83d Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/478120 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
1d94a0b0e1
commit
7d3d2b62e8
@ -521,25 +521,23 @@ spdk_thread_poll(struct spdk_thread *thread, uint32_t max_msgs, uint64_t now)
|
|||||||
poller->state = SPDK_POLLER_STATE_RUNNING;
|
poller->state = SPDK_POLLER_STATE_RUNNING;
|
||||||
timer_rc = poller->fn(poller->arg);
|
timer_rc = poller->fn(poller->arg);
|
||||||
|
|
||||||
if (poller->state == SPDK_POLLER_STATE_UNREGISTERED) {
|
|
||||||
TAILQ_REMOVE(&thread->timer_pollers, poller, tailq);
|
|
||||||
free(poller);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
poller->state = SPDK_POLLER_STATE_WAITING;
|
|
||||||
TAILQ_REMOVE(&thread->timer_pollers, poller, tailq);
|
|
||||||
_spdk_poller_insert_timer(thread, poller, now);
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (timer_rc == -1) {
|
if (timer_rc == -1) {
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_THREAD, "Timed poller %p returned -1\n", poller);
|
SPDK_DEBUGLOG(SPDK_LOG_THREAD, "Timed poller %p returned -1\n", poller);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (poller->state == SPDK_POLLER_STATE_UNREGISTERED) {
|
||||||
|
TAILQ_REMOVE(&thread->timer_pollers, poller, tailq);
|
||||||
|
free(poller);
|
||||||
|
} else {
|
||||||
|
poller->state = SPDK_POLLER_STATE_WAITING;
|
||||||
|
TAILQ_REMOVE(&thread->timer_pollers, poller, tailq);
|
||||||
|
_spdk_poller_insert_timer(thread, poller, now);
|
||||||
|
}
|
||||||
|
|
||||||
if (timer_rc > rc) {
|
if (timer_rc > rc) {
|
||||||
rc = timer_rc;
|
rc = timer_rc;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user