diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-01-24 01:40:51 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-01-24 01:40:51 -0800 |
| commit | 107e8a56ea0fee9eff996177003b32a0179d7651 (patch) | |
| tree | 9b16183cb0e27f5ef6ada86666370511d86ba735 /weed/util/grpc_client_server.go | |
| parent | 2f75264ec7928e362f54d0be2453168d21c82834 (diff) | |
| download | seaweedfs-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.go | 9 |
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...) |
