mirror of
https://github.com/minio/minio.git
synced 2024-12-25 14:45:54 -05:00
Add extra protection for grid reconnects (#18840)
Race checks would occasionally show race on handleMsgWg WaitGroup by debug messages (used in test only). Use the `connMu` mutex to protect this against concurrent Wait/Add. Fixes #18827
This commit is contained in:
parent
65c4d550cb
commit
feeeef71f1
@ -831,7 +831,9 @@ func (c *Connection) reconnected() {
|
||||
c.outgoing.Clear()
|
||||
|
||||
// Wait for existing to exit
|
||||
c.connMu.Lock()
|
||||
c.handleMsgWg.Wait()
|
||||
c.connMu.Unlock()
|
||||
}
|
||||
|
||||
func (c *Connection) updateState(s State) {
|
||||
@ -855,7 +857,9 @@ func (c *Connection) updateState(s State) {
|
||||
|
||||
func (c *Connection) handleMessages(ctx context.Context, conn net.Conn) {
|
||||
// Read goroutine
|
||||
c.connMu.Lock()
|
||||
c.handleMsgWg.Add(2)
|
||||
c.connMu.Unlock()
|
||||
ctx, cancel := context.WithCancelCause(ctx)
|
||||
go func() {
|
||||
defer func() {
|
||||
@ -1534,7 +1538,9 @@ func (c *Connection) debugMsg(d debugMsg, args ...any) {
|
||||
c.debugInConn.Close()
|
||||
}
|
||||
case debugWaitForExit:
|
||||
c.connMu.Lock()
|
||||
c.handleMsgWg.Wait()
|
||||
c.connMu.Unlock()
|
||||
case debugSetConnPingDuration:
|
||||
c.connMu.Lock()
|
||||
defer c.connMu.Unlock()
|
||||
|
Loading…
Reference in New Issue
Block a user