mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-02 14:17:19 +00:00
fix: drain regWait channel before closing to prevent message loss
- Add drain loop before closing regWait in reconnect() cleanup - Add drain loop before closing regWait in handleDisconnect() cleanup - Ensures no pending RegistrationResponse messages are lost during channel closure
This commit is contained in:
+22
-4
@@ -270,8 +270,17 @@ func (c *GrpcAdminClient) reconnect(s *grpcState) error {
|
||||
c.safeCloseChannel(&s.streamExit)
|
||||
c.safeCloseChannel(&s.streamFailed)
|
||||
if s.regWait != nil {
|
||||
close(s.regWait)
|
||||
s.regWait = nil
|
||||
// Drain any pending registration responses before closing to avoid losing them
|
||||
for {
|
||||
select {
|
||||
case <-s.regWait:
|
||||
// continue draining until channel is empty
|
||||
default:
|
||||
close(s.regWait)
|
||||
s.regWait = nil
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if s.streamCancel != nil {
|
||||
s.streamCancel()
|
||||
@@ -552,8 +561,17 @@ func (c *GrpcAdminClient) handleDisconnect(cmd grpcCommand, s *grpcState) {
|
||||
c.safeCloseChannel(&s.streamExit)
|
||||
c.safeCloseChannel(&s.streamFailed)
|
||||
if s.regWait != nil {
|
||||
close(s.regWait)
|
||||
s.regWait = nil
|
||||
// Drain any pending registration responses before closing to avoid losing them
|
||||
for {
|
||||
select {
|
||||
case <-s.regWait:
|
||||
// continue draining until channel is empty
|
||||
default:
|
||||
close(s.regWait)
|
||||
s.regWait = nil
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Cancel stream context
|
||||
|
||||
Reference in New Issue
Block a user