1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-11-23 21:44:41 +02:00

Patch for potential deadlock

This commit is contained in:
Asim Aslam
2025-10-07 16:20:45 +00:00
parent 3d6b6521ab
commit aa2ed9aa91

View File

@@ -329,6 +329,10 @@ func (s *rpcServer) ServeConn(sock transport.Socket) {
// Process the outbound messages from the socket
go func(psock *socket.Socket) {
defer func() {
if r := recover(); r != nil {
logger.Log(log.ErrorLevel, "panic recovered in outbound goroutine: ", r)
logger.Log(log.ErrorLevel, string(debug.Stack()))
}
// 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
if protocol == "grpc" {
@@ -356,7 +360,13 @@ func (s *rpcServer) ServeConn(sock transport.Socket) {
// Serve the request in a go routine as this may be a stream
go func(psock *socket.Socket) {
defer s.deferer(pool, psock, wg)
defer func() {
if r := recover(); r != nil {
logger.Log(log.ErrorLevel, "panic recovered in serveReq goroutine: ", r)
logger.Log(log.ErrorLevel, string(debug.Stack()))
}
s.deferer(pool, psock, wg)
}()
s.serveReq(ctx, msg, &request, &response, rcodec)
}(psock)