http3: use the stream context to detect when the send side is closed (#4489)

This commit is contained in:
Marten Seemann
2024-05-05 10:15:35 +08:00
committed by GitHub
parent c7b58b568f
commit bb6f066aa5
7 changed files with 111 additions and 33 deletions

View File

@@ -1,6 +1,7 @@
package http3
import (
"context"
"errors"
"sync"
@@ -26,6 +27,9 @@ type stateTrackingStream struct {
}
func newStateTrackingStream(s quic.Stream, onStateChange func(streamState, error)) *stateTrackingStream {
context.AfterFunc(s.Context(), func() {
onStateChange(streamStateSendClosed, context.Cause(s.Context()))
})
return &stateTrackingStream{
Stream: s,
state: streamStateOpen,