defer wg.Done so it's called even if there's a panic
This commit is contained in:
parent
32b7ebcfbc
commit
3812cbbcb6
@ -104,16 +104,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 {
|
||||
log.Logf("Unexpected error serving request, closing socket: %v", err)
|
||||
s.wg.Done()
|
||||
return
|
||||
}
|
||||
|
||||
// finish request
|
||||
s.wg.Done()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -228,12 +228,12 @@ func (s *rpcServer) createSubHandler(sb *subscriber, opts Options) broker.Handle
|
||||
|
||||
s.wg.Add(1)
|
||||
go func() {
|
||||
defer s.wg.Done()
|
||||
fn(ctx, &rpcPublication{
|
||||
topic: sb.topic,
|
||||
contentType: ct,
|
||||
message: req.Interface(),
|
||||
})
|
||||
s.wg.Done()
|
||||
}()
|
||||
}
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user