aboutsummaryrefslogtreecommitdiff
path: root/weed/util/grpc_client_server.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-01-24 01:40:51 -0800
committerChris Lu <chris.lu@gmail.com>2020-01-24 01:40:51 -0800
commit107e8a56ea0fee9eff996177003b32a0179d7651 (patch)
tree9b16183cb0e27f5ef6ada86666370511d86ba735 /weed/util/grpc_client_server.go
parent2f75264ec7928e362f54d0be2453168d21c82834 (diff)
downloadseaweedfs-107e8a56ea0fee9eff996177003b32a0179d7651.tar.xz
seaweedfs-107e8a56ea0fee9eff996177003b32a0179d7651.zip
retry context canceled request
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...)