From 5f7cc43ba12c87b70fe1e8f8f225258e718048ba Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 14 Feb 2024 14:03:26 -0500 Subject: ioq: Replay IOQ_STOP messages rather than spam them --- src/ioq.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ioq.c b/src/ioq.c index 438601d..ede2413 100644 --- a/src/ioq.c +++ b/src/ioq.c @@ -511,9 +511,11 @@ static struct ioq_ent *ioq_ring_pop(struct ioq_ring_state *state) { // Block if we have nothing else to do bool block = !state->prepped && !state->submitted; - struct ioq_ent *ret = ioqq_pop(state->ioq->pending, block); + struct ioqq *pending = state->ioq->pending; + struct ioq_ent *ret = ioqq_pop(pending, block); if (ret == &IOQ_STOP) { + ioqq_push(pending, &IOQ_STOP); state->stop = true; ret = NULL; } @@ -685,6 +687,7 @@ static void ioq_sync_work(struct ioq_thread *thread) { while (true) { struct ioq_ent *ent = ioqq_pop(ioq->pending, true); if (ent == &IOQ_STOP) { + ioqq_push(ioq->pending, &IOQ_STOP); break; } @@ -884,9 +887,7 @@ void ioq_free(struct ioq *ioq, struct ioq_ent *ent) { void ioq_cancel(struct ioq *ioq) { if (!exchange(&ioq->cancel, true, relaxed)) { - for (size_t i = 0; i < ioq->nthreads; ++i) { - ioqq_push(ioq->pending, &IOQ_STOP); - } + ioqq_push(ioq->pending, &IOQ_STOP); } } -- cgit v1.2.3