From 3e6ac73cfe791152a54fdfcc114bd34be67a2956 Mon Sep 17 00:00:00 2001 From: Di Wu Date: Sun, 28 Jun 2020 03:07:04 +0800 Subject: [PATCH] Fix invalid usage for sync.WaitGroup (#1752) * Custom private blocks * Fix invalid usage for sync.WaitGroup Co-authored-by: Asim Aslam --- server/rpc_server.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/server/rpc_server.go b/server/rpc_server.go index 212d539a..eda90942 100644 --- a/server/rpc_server.go +++ b/server/rpc_server.go @@ -363,11 +363,12 @@ func (s *rpcServer) ServeConn(sock transport.Socket) { r = rpcRouter{h: handler} } + // wait for two coroutines to exit + // serve the request and process the outbound messages + wg.Add(2) + // process the outbound messages from the socket go func(id string, psock *socket.Socket) { - // wait for processing to exit - wg.Add(1) - defer func() { // TODO: don't hack this but if its grpc just break out of the stream // We do this because the underlying connection is h2 and its a stream @@ -405,9 +406,6 @@ func (s *rpcServer) ServeConn(sock transport.Socket) { // serve the request in a go routine as this may be a stream go func(id string, psock *socket.Socket) { - // add to the waitgroup - wg.Add(1) - defer func() { // release the socket pool.Release(psock)