MCPcopy
hub / github.com/caddyserver/caddy / closeConnections

Method closeConnections

modules/caddyhttp/reverseproxy/streaming.go:403–424  ·  view source on GitHub ↗

closeConnections immediately closes all hijacked connections (both to client and backend).

()

Source from the content-addressed store, hash-verified

401
402// closeConnections immediately closes all hijacked connections (both to client and backend).
403func (h *Handler) closeConnections() error {
404 var err error
405 h.connectionsMu.Lock()
406 defer h.connectionsMu.Unlock()
407
408 for _, oc := range h.connections {
409 if oc.gracefulClose != nil {
410 // this is potentially blocking while we have the lock on the connections
411 // map, but that should be OK since the server has in theory shut down
412 // and we are no longer using the connections map
413 gracefulErr := oc.gracefulClose()
414 if gracefulErr != nil && err == nil {
415 err = gracefulErr
416 }
417 }
418 closeErr := oc.conn.Close()
419 if closeErr != nil && err == nil {
420 err = closeErr
421 }
422 }
423 return err
424}
425
426// cleanupConnections closes hijacked connections.
427// Depending on the value of StreamCloseDelay it does that either immediately

Callers 1

cleanupConnectionsMethod · 0.95

Calls 1

CloseMethod · 0.45

Tested by

no test coverage detected