closeStream clears the footprint of a stream when the stream is not needed any more.
(s *ServerStream, rst bool, rstCode http2.ErrCode, eosReceived bool)
| 1350 | |
| 1351 | // closeStream clears the footprint of a stream when the stream is not needed any more. |
| 1352 | func (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 | |
| 1372 | func (t *http2Server) Drain(debugData string) { |
| 1373 | t.mu.Lock() |