aboutsummaryrefslogtreecommitdiff
path: root/weed/util/grpc_client_server.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/util/grpc_client_server.go')
-rw-r--r--weed/util/grpc_client_server.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/weed/util/grpc_client_server.go b/weed/util/grpc_client_server.go
index 31497ad35..63519d97a 100644
--- a/weed/util/grpc_client_server.go
+++ b/weed/util/grpc_client_server.go
@@ -64,7 +64,14 @@ func WithCachedGrpcClient(ctx context.Context, fn func(*grpc.ClientConn) error,
existingConnection, found := grpcClients[address]
if found {
grpcClientsLock.Unlock()
- return fn(existingConnection)
+ err := fn(existingConnection)
+ if err != nil {
+ grpcClientsLock.Lock()
+ delete(grpcClients, address)
+ grpcClientsLock.Unlock()
+ existingConnection.Close()
+ }
+ return err
}
grpcConnection, err := GrpcDial(ctx, address, opts...)