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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
3 additions and
3 deletions
-
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() |
|
|
|
|
|
|
|