Let the bridge's own timeout, refusal and two-phase poll be seen
Three rules the bridge has always promised, none of which anything committed could see. The timeout was the structural one. Both scenarios end their waits with a close, so the duration the bridge waits on governed nothing either of them observes: a hard-coded 2000 ms survived the whole Linux matrix and Windows, and a host asking for five seconds would have got two forever with nothing reporting it. The fix is not another entry at another constant. A timeout's only observable is how long the call takes, so `polltimeout` lets an idle runtime's poll be ended by its own timeout and measures it, twice at different values, because no single constant sits in both bands. The seam's hold moves behind that too: it parks only a call the wait woke, so a poll whose own timeout expired is on its way out rather than held there by the fixture and counted as the bridge's doing. The refusal during a close (the header's section 4) had no scenario at all. A call admitted after the closer has begun increments the in-flight count behind a wait that has already read it. `latecall` holds the close open with the seam and makes a call into it. And the two-phase poll was written off as needing a listener, a credential and a connection. It needs a closed loopback port: the failure always carries a reason, which is an 87-byte payload, in about a millisecond. Moving the pop above the copy crashes on both targets. 18 killed, 0 survived, 0 skipped on linux-x64; 16 killed, 0 survived on win32-x64, where the two ThreadSanitizer entries are honestly skipped. Both runs restored the source to the same sha256, b163cab7d48ebc93. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
25d7de26b3
commit
a937a0b07e
3 changed files with 517 additions and 33 deletions
|
|
@ -83,9 +83,11 @@
|
|||
// - HELD parks a call inside the library until the scenario releases it, so the
|
||||
// close races calls that are genuinely there for as long as the scenario
|
||||
// wants them there, instead of for as long as the schedule happens to give.
|
||||
// It returns true when it parked, and touches nothing afterwards: a bridge
|
||||
// that frees the runtime out from under a held call is then reported by the
|
||||
// scenario rather than crashing inside it.
|
||||
// It returns true when it parked, and a held call makes no further call of
|
||||
// its own; what it does still do is leave its CallScope, which takes the gate,
|
||||
// decrements the count and notifies. That is the ordinary exit every export
|
||||
// makes, and it is the bridge's wait — not the hold — that keeps the runtime
|
||||
// alive underneath it.
|
||||
#if defined(CULTMESH_QUIC_DEBUG_ASSERTS)
|
||||
#define CULTMESH_QUIC_DEBUG_PEAK(count) DebugRaisePeak(count)
|
||||
#define CULTMESH_QUIC_DEBUG_AT_CLOSE(count) DebugRecordCallsAtClose(count)
|
||||
|
|
@ -1172,12 +1174,16 @@ CULTMESH_API int32_t cultmesh_quic_next_event(
|
|||
|
||||
std::unique_lock<std::mutex> lock(runtime->gate);
|
||||
if (runtime->events.empty() && timeout_ms > 0) {
|
||||
runtime->signal.wait_for(lock, std::chrono::milliseconds(timeout_ms),
|
||||
// The host's timeout bounds the wait; an event or the close ends it
|
||||
// sooner, and `woken` is which of the two happened.
|
||||
const bool woken = runtime->signal.wait_for(lock, std::chrono::milliseconds(timeout_ms),
|
||||
[runtime] { return !runtime->events.empty() || runtime->closing; });
|
||||
// Development builds only; a no-op unless a scenario has armed the hold.
|
||||
// A held call returns the same 0 an empty queue would have, and touches
|
||||
// the runtime no further.
|
||||
if (CULTMESH_QUIC_DEBUG_HELD(lock)) return 0;
|
||||
// A held call returns the same 0 an empty queue would have, and makes no
|
||||
// further call of its own. Only a woken call is held: one whose own
|
||||
// timeout expired is on its way out, and parking it would let a scenario
|
||||
// report a call the bridge kept when what kept it was the fixture.
|
||||
if (woken && CULTMESH_QUIC_DEBUG_HELD(lock)) return 0;
|
||||
}
|
||||
if (runtime->events.empty()) return 0;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue