Skip to content

Commit

Permalink
Fix invalid usage for sync.WaitGroup (micro#1752)
Browse files Browse the repository at this point in the history
* Custom private blocks

* Fix invalid usage for sync.WaitGroup

Co-authored-by: Asim Aslam <[email protected]>
  • Loading branch information
wudi and asim authored Jun 27, 2020
1 parent 5967a68 commit 132c1e3
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions server/rpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 132c1e3

Please sign in to comment.