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

Method Close

internal/transport/http2_server.go:1281–1304  ·  view source on GitHub ↗

Close starts shutting down the http2Server transport. TODO(zhaoq): Now the destruction is not blocked on any pending streams. This could cause some resource issue. Revisit this later.

(err error)

Source from the content-addressed store, hash-verified

1279// TODO(zhaoq): Now the destruction is not blocked on any pending streams. This
1280// could cause some resource issue. Revisit this later.
1281func (t *http2Server) Close(err error) {
1282 t.mu.Lock()
1283 if t.state == closing {
1284 t.mu.Unlock()
1285 return
1286 }
1287 if t.logger.V(logLevel) {
1288 t.logger.Infof("Closing: %v", err)
1289 }
1290 t.state = closing
1291 streams := t.activeStreams
1292 t.activeStreams = nil
1293 t.mu.Unlock()
1294 t.controlBuf.finish()
1295 close(t.done)
1296 if err := t.conn.Close(); err != nil && t.logger.V(logLevel) {
1297 t.logger.Infof("Error closing underlying net.Conn during Close: %v", err)
1298 }
1299 channelz.RemoveEntry(t.channelz.ID)
1300 // Cancel all active streams.
1301 for _, s := range streams {
1302 s.cancel()
1303 }
1304}
1305
1306// deleteStream deletes the stream s from transport's active streams.
1307func (t *http2Server) deleteStream(s *ServerStream, eosReceived bool) {

Callers 4

NewServerTransportFunction · 0.95
HandleStreamsMethod · 0.95
keepaliveMethod · 0.95

Calls 8

RemoveEntryFunction · 0.92
cancelMethod · 0.80
VMethod · 0.65
InfofMethod · 0.65
CloseMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45
finishMethod · 0.45

Tested by 1