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
|
// add to wait group
|
||||||
s.wg.Add(1)
|
s.wg.Add(1)
|
||||||
|
defer s.wg.Done()
|
||||||
|
|
||||||
// TODO: needs better error handling
|
// TODO: needs better error handling
|
||||||
if err := s.rpc.serveRequest(ctx, codec, ct); err != nil {
|
if err := s.rpc.serveRequest(ctx, codec, ct); err != nil {
|
||||||
log.Logf("Unexpected error serving request, closing socket: %v", err)
|
log.Logf("Unexpected error serving request, closing socket: %v", err)
|
||||||
s.wg.Done()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// finish request
|
|
||||||
s.wg.Done()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,12 +228,12 @@ func (s *rpcServer) createSubHandler(sb *subscriber, opts Options) broker.Handle
|
|||||||
|
|
||||||
s.wg.Add(1)
|
s.wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
|
defer s.wg.Done()
|
||||||
fn(ctx, &rpcPublication{
|
fn(ctx, &rpcPublication{
|
||||||
topic: sb.topic,
|
topic: sb.topic,
|
||||||
contentType: ct,
|
contentType: ct,
|
||||||
message: req.Interface(),
|
message: req.Interface(),
|
||||||
})
|
})
|
||||||
s.wg.Done()
|
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user