MCPcopy
hub / github.com/grpc/grpc-go / closeStream

Method closeStream

internal/transport/http2_server.go:1352–1370  ·  view source on GitHub ↗

closeStream clears the footprint of a stream when the stream is not needed any more.

(s *ServerStream, rst bool, rstCode http2.ErrCode, eosReceived bool)

Source from the content-addressed store, hash-verified

1350
1351// closeStream clears the footprint of a stream when the stream is not needed any more.
1352func (t *http2Server) closeStream(s *ServerStream, rst bool, rstCode http2.ErrCode, eosReceived bool) {
1353 // In case stream sending and receiving are invoked in separate
1354 // goroutines (e.g., bi-directional streaming), cancel needs to be
1355 // called to interrupt the potential blocking on other goroutines.
1356 s.cancel()
1357
1358 // We can't return early even if the stream's state is "done" as the state
1359 // might have been set by the `finishStream` method. Deleting the stream via
1360 // `finishStream` can get blocked on flow control.
1361 s.swapState(streamDone)
1362 t.deleteStream(s, eosReceived)
1363
1364 t.controlBuf.put(&cleanupStream{
1365 streamID: s.id,
1366 rst: rst,
1367 rstCode: rstCode,
1368 onWrite: func() {},
1369 })
1370}
1371
1372func (t *http2Server) Drain(debugData string) {
1373 t.mu.Lock()

Callers 8

operateHeadersMethod · 0.95
HandleStreamsMethod · 0.95
handleDataMethod · 0.95
handleRSTStreamMethod · 0.95
writeHeaderLockedMethod · 0.95
writeStatusMethod · 0.95
CloseMethod · 0.45

Calls 4

deleteStreamMethod · 0.95
cancelMethod · 0.80
swapStateMethod · 0.80
putMethod · 0.45