From b4f47b1cc9c47965aec8ff93bca322c69df3bff6 Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Sat, 26 May 2018 09:10:29 +0100 Subject: [PATCH 1/2] Set the default pool size to 1 --- client/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/client.go b/client/client.go index 78352657..87cdad01 100644 --- a/client/client.go +++ b/client/client.go @@ -74,7 +74,7 @@ var ( // DefaultRequestTimeout is the default request timeout DefaultRequestTimeout = time.Second * 5 // DefaultPoolSize sets the connection pool size - DefaultPoolSize = 0 + DefaultPoolSize = 1 // DefaultPoolTTL sets the connection pool ttl DefaultPoolTTL = time.Minute ) From a56e97b47d989b216b67bedbbe0963c65c7ccb4e Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Sat, 26 May 2018 09:41:41 +0100 Subject: [PATCH 2/2] Change waitgroup processing --- server/rpc_server.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/server/rpc_server.go b/server/rpc_server.go index e600fb60..a725bf29 100644 --- a/server/rpc_server.go +++ b/server/rpc_server.go @@ -66,6 +66,9 @@ func (s *rpcServer) accept(sock transport.Socket) { return } + // add to wait group + s.wg.Add(1) + // we use this Timeout header to set a server deadline to := msg.Header["Timeout"] // we use this Content-Type header to identify the codec needed @@ -80,6 +83,7 @@ func (s *rpcServer) accept(sock transport.Socket) { }, Body: []byte(err.Error()), }) + s.wg.Done() return } @@ -102,15 +106,13 @@ func (s *rpcServer) accept(sock transport.Socket) { } } - // add to wait group - s.wg.Add(1) - defer s.wg.Done() - // TODO: needs better error handling if err := s.rpc.serveRequest(ctx, codec, ct); err != nil { + s.wg.Done() log.Logf("Unexpected error serving request, closing socket: %v", err) return } + s.wg.Done() } }