fix: close stream adaptive gaps and switch notify to stario v0.1.1
- make stream fast path honor adaptive soft payload limits end-to-end - split oversized fast-stream payloads into sequential frames before batching - use adaptive soft cap when encoding stream batch payloads - move timeout-like error detection into production code for adaptive tx - tune notify FrameReader read size explicitly to avoid throughput regression - drop local stario replace and depend on released b612.me/stario v0.1.1
This commit is contained in:
@@ -105,3 +105,51 @@ func TestStreamFlowControllerAdmitsRequestsFIFO(t *testing.T) {
|
||||
t.Fatalf("second admitted request = %d, want 3", second)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStreamFlowControllerTryAcquireDoesNotBypassQueuedWaiter(t *testing.T) {
|
||||
controller := newStreamFlowController(streamConfig{
|
||||
ChunkSize: 4,
|
||||
InboundQueueLimit: 1,
|
||||
InboundBufferedBytesLimit: 4,
|
||||
OutboundWindowBytes: 4,
|
||||
OutboundMaxInFlightChunks: 1,
|
||||
})
|
||||
|
||||
releaseFirst, err := controller.acquire(context.Background(), 4)
|
||||
if err != nil {
|
||||
t.Fatalf("first acquire failed: %v", err)
|
||||
}
|
||||
defer releaseFirst()
|
||||
|
||||
waiterReady := make(chan struct{})
|
||||
waiterAcquired := make(chan func(), 1)
|
||||
go func() {
|
||||
close(waiterReady)
|
||||
releaseSecond, err := controller.acquire(context.Background(), 4)
|
||||
if err != nil {
|
||||
t.Errorf("waiter acquire failed: %v", err)
|
||||
return
|
||||
}
|
||||
waiterAcquired <- releaseSecond
|
||||
}()
|
||||
|
||||
<-waiterReady
|
||||
time.Sleep(20 * time.Millisecond)
|
||||
|
||||
if controller.tryAcquire(4) {
|
||||
t.Fatal("tryAcquire should not bypass queued waiter")
|
||||
}
|
||||
|
||||
releaseFirst()
|
||||
|
||||
var releaseSecond func()
|
||||
select {
|
||||
case releaseSecond = <-waiterAcquired:
|
||||
case <-time.After(time.Second):
|
||||
t.Fatal("timed out waiting for queued waiter to acquire")
|
||||
}
|
||||
if releaseSecond == nil {
|
||||
t.Fatal("queued waiter returned nil release func")
|
||||
}
|
||||
releaseSecond()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user