Commit 7d3d2b62 authored by Jim Harris's avatar Jim Harris Committed by Tomasz Zawadzki
Browse files

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: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I0673261ecea0e49db97b008a83b60a35f995f83d

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/478120


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarPaul Luse <paul.e.luse@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 1d94a0b0
Loading
Loading
Loading
Loading
+9 −11
Original line number Diff line number Diff line
@@ -521,25 +521,23 @@ spdk_thread_poll(struct spdk_thread *thread, uint32_t max_msgs, uint64_t now)
		poller->state = SPDK_POLLER_STATE_RUNNING;
		timer_rc = poller->fn(poller->arg);

#ifdef DEBUG
		if (timer_rc == -1) {
			SPDK_DEBUGLOG(SPDK_LOG_THREAD, "Timed poller %p returned -1\n", poller);
		}
#endif

		if (poller->state == SPDK_POLLER_STATE_UNREGISTERED) {
			TAILQ_REMOVE(&thread->timer_pollers, poller, tailq);
			free(poller);
			continue;
		}

		} else {
			poller->state = SPDK_POLLER_STATE_WAITING;
			TAILQ_REMOVE(&thread->timer_pollers, poller, tailq);
			_spdk_poller_insert_timer(thread, poller, now);

#ifdef DEBUG
		if (timer_rc == -1) {
			SPDK_DEBUGLOG(SPDK_LOG_THREAD, "Timed poller %p returned -1\n", poller);
		}
#endif

		if (timer_rc > rc) {
			rc = timer_rc;

		}
	}