Browse Source

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.
pull/7838/head
Chris Lu 2 months ago
parent
commit
4f05f657de
  1. 5
      weed/worker/client.go

5
weed/worker/client.go

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

Loading…
Cancel
Save