Browse Source

Refactor connection locking to use read lock

Changed locking mechanism to use read lock for connection check.
pull/7341/head
Mariano Ntrougkas 1 day ago
committed by GitHub
parent
commit
6afb215607
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 6
      weed/worker/client.go

6
weed/worker/client.go

@ -73,13 +73,13 @@ func NewGrpcAdminClient(adminAddress string, workerID string, dialOption grpc.Di
// Connect establishes gRPC connection to admin server with TLS detection
func (c *GrpcAdminClient) Connect() error {
c.mutex.Lock()
defer c.mutex.Unlock()
c.mutex.RLock()
if c.connected {
c.mutex.RUnlock()
return fmt.Errorf("already connected")
}
c.mutex.RUnlock()
// Always start the reconnection loop, even if initial connection fails
go c.reconnectionLoop()

Loading…
Cancel
Save