From e461dfb7a702299494d6bbb264b26a06c7103153 Mon Sep 17 00:00:00 2001 From: nicolas Date: Thu, 28 May 2026 22:27:33 -0300 Subject: [PATCH] fix: keep slot IN_FLIGHT during execution so evaluator sees busy and drops instead of queuing --- src/events.c | 4 +++- src/slot.h | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/events.c b/src/events.c index 7dd3f10..ace167f 100644 --- a/src/events.c +++ b/src/events.c @@ -238,13 +238,15 @@ void *event_executor_thread(void *arg) { /* Fast path: check slot state without poll */ if (atomic_load_explicit(&slot->state, memory_order_acquire) == EXECUTOR_SLOT_READY) { signal_entry_t sig = slot->signal; - atomic_store_explicit(&slot->state, EXECUTOR_SLOT_FREE, memory_order_release); + atomic_store_explicit(&slot->state, EXECUTOR_SLOT_IN_FLIGHT, memory_order_release); /* Drain eventfd so poll can block next time */ uint64_t val; if (read(slot->eventfd, &val, sizeof(val)) < 0) {} executor_execute_triangle(exec, &sig); + atomic_store_explicit(&slot->state, EXECUTOR_SLOT_FREE, memory_order_release); + int64_t now = now_mono_ms(); if (last_keepalive_ms == 0 || now - last_keepalive_ms >= 30000) { executor_keepalive(exec); diff --git a/src/slot.h b/src/slot.h index 8e60dc5..abd590e 100644 --- a/src/slot.h +++ b/src/slot.h @@ -5,9 +5,10 @@ #include #include "triangle.h" -#define EXECUTOR_SLOT_FREE 0 -#define EXECUTOR_SLOT_CLAIMED 1 -#define EXECUTOR_SLOT_READY 2 +#define EXECUTOR_SLOT_FREE 0 +#define EXECUTOR_SLOT_CLAIMED 1 +#define EXECUTOR_SLOT_READY 2 +#define EXECUTOR_SLOT_IN_FLIGHT 3 typedef struct { _Atomic int state;