fix(worker): review follow-up — ghost cache entries, ReadBulk dedupe/pumping, fault hygiene
- AddItem/AddItem2/AddBufferedItem drop stale cache entries for a reused handle id - ReadBulk: dedupe handles within a batch (advise/teardown once, fan out result); pump every 16 items in add/advise and teardown phases - alarm poll stops without recording a fault once StaRuntime.LoopFault is set - StaRuntime skips the loop-fault handler during a requested shutdown - StaHung loop fault diagnostic carries type + HRESULT only - gateway.md documents ReadBulk's shared deadline
This commit is contained in:
@@ -274,6 +274,27 @@ public sealed class StaRuntimeTests
|
||||
Assert.False(invoked);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A loop that throws while a requested shutdown is in progress is
|
||||
/// being torn down on purpose: the loop-fault handler must not run.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void LoopException_DuringRequestedShutdown_DoesNotInvokeHandler()
|
||||
{
|
||||
ControllableMessagePump pump = new();
|
||||
using StaRuntime runtime = new(new RecordingComApartmentInitializer(), pump, TimeSpan.FromSeconds(30));
|
||||
runtime.Start();
|
||||
bool invoked = false;
|
||||
runtime.RegisterLoopFaultHandler(_ => invoked = true);
|
||||
|
||||
// The loop is parked in the 30 s idle wait; Shutdown wakes it and the
|
||||
// very next pump throws with shutdownRequested already set.
|
||||
pump.ThrowOnNextPump(new InvalidOperationException("pump failed during shutdown"));
|
||||
Assert.True(runtime.Shutdown(TimeSpan.FromSeconds(5)));
|
||||
|
||||
Assert.False(invoked);
|
||||
}
|
||||
|
||||
private static StaRuntime CreateRuntime(RecordingComApartmentInitializer initializer)
|
||||
{
|
||||
return new StaRuntime(
|
||||
|
||||
Reference in New Issue
Block a user