diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2024-02-14 14:03:26 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2024-02-14 14:03:26 -0500 |
commit | 5f7cc43ba12c87b70fe1e8f8f225258e718048ba (patch) | |
tree | 317c5973df749816919a21f8d205db73dca4b76a | |
parent | 2fe4c9922bd02e0ec4bca8151cbff1a0bcf29dcf (diff) | |
download | bfs-5f7cc43ba12c87b70fe1e8f8f225258e718048ba.tar.xz |
ioq: Replay IOQ_STOP messages rather than spam them
-rw-r--r-- | src/ioq.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -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); } } |