Properly close regWait channel in reconnect to prevent resource leaks

Close the regWait channel before setting it to nil in reconnect(), matching the
pattern used in handleDisconnect(). This ensures any goroutines waiting on this
channel during reconnection are properly signaled, preventing them from hanging.
This commit is contained in:
Chris Lu
2025-12-22 00:52:15 -08:00
parent 7e0664aee9
commit 4f05f657de

View File

@@ -269,7 +269,10 @@ func (c *GrpcAdminClient) reconnect(s *grpcState) error {
// Clean up existing connection completely
c.safeCloseChannel(&s.streamExit)
c.safeCloseChannel(&s.streamFailed)
s.regWait = nil
if s.regWait != nil {
close(s.regWait)
s.regWait = nil
}
if s.streamCancel != nil {
s.streamCancel()
}