Fix invalid usage for sync.WaitGroup (#1752)

* Custom private blocks

* Fix invalid usage for sync.WaitGroup

Co-authored-by: Asim Aslam <asim@aslam.me>
This commit is contained in:
Di Wu 2020-06-28 03:07:04 +08:00 committed by GitHub
parent 5967a68e78
commit 132c1e35fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)