From eeb13f1ca8a5e801804343310d1cf73e1e9848fc Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Sat, 25 Apr 2026 05:42:43 -0400 Subject: [PATCH] More comments --- modules/caddyhttp/reverseproxy/streaming.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/caddyhttp/reverseproxy/streaming.go b/modules/caddyhttp/reverseproxy/streaming.go index 7cb7ff7da..a50e615e4 100644 --- a/modules/caddyhttp/reverseproxy/streaming.go +++ b/modules/caddyhttp/reverseproxy/streaming.go @@ -485,6 +485,8 @@ func (h Handler) copyBuffer(dst io.Writer, src io.Reader, buf []byte, logger *za // openConnection maps an open connection to an optional function for graceful // close and records which upstream address the connection is proxying to. +// Also tracks whether the connection is detached, which means it should only be +// closed when the upstream is removed from the config, not on every reload. type openConnection struct { conn io.ReadWriteCloser gracefulClose func() error @@ -493,6 +495,9 @@ type openConnection struct { } // tunnelTracker tracks hijacked/upgraded connections for selective cleanup. +// This exists to detach the lifecycle of streaming connections from the proxy +// Handler and config, since we typically want them to survive past config reloads. +// It also allows for selective connection cleanup based on their attachment status. type tunnelTracker struct { connections map[io.ReadWriteCloser]openConnection closeTimer *time.Timer