summaryrefslogtreecommitdiffstats
path: root/src/ioq.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-02-14 14:03:26 -0500
committerTavian Barnes <tavianator@tavianator.com>2024-02-14 14:03:26 -0500
commit5f7cc43ba12c87b70fe1e8f8f225258e718048ba (patch)
tree317c5973df749816919a21f8d205db73dca4b76a /src/ioq.c
parent2fe4c9922bd02e0ec4bca8151cbff1a0bcf29dcf (diff)
downloadbfs-5f7cc43ba12c87b70fe1e8f8f225258e718048ba.tar.xz
ioq: Replay IOQ_STOP messages rather than spam them
Diffstat (limited to 'src/ioq.c')
-rw-r--r--src/ioq.c9
1 files changed, 5 insertions, 4 deletions
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);
}
}