From e11e127d91c3a6e1f4b13243a9c7cd1980159dd9 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Thu, 11 Apr 2019 09:27:05 -0700 Subject: [PATCH] close grpc connections during errors --- weed/util/grpc_client_server.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/weed/util/grpc_client_server.go b/weed/util/grpc_client_server.go index 5c08538dc..c35a13970 100644 --- a/weed/util/grpc_client_server.go +++ b/weed/util/grpc_client_server.go @@ -19,7 +19,7 @@ var ( grpcClientsLock sync.Mutex ) -func init(){ +func init() { http.DefaultTransport.(*http.Transport).MaxIdleConnsPerHost = 100 } @@ -81,6 +81,7 @@ func WithCachedGrpcClient(ctx context.Context, fn func(*grpc.ClientConn) error, grpcClientsLock.Lock() delete(grpcClients, address) grpcClientsLock.Unlock() + grpcConnection.Close() } return err