1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-24 10:07:04 +02:00

continue to process messages even after the connection is closed

This commit is contained in:
Asim Aslam 2020-01-03 20:43:53 +00:00
parent 649dd235c3
commit df9055f69c

View File

@ -173,6 +173,25 @@ func (s *session) waitFor(msgType string, timeout time.Duration) (*message, erro
case <-after(timeout): case <-after(timeout):
return nil, ErrReadTimeout return nil, ErrReadTimeout
case <-s.closed: case <-s.closed:
// check pending message queue
select {
case msg := <-s.recv:
// there may be no message type
if len(msgType) == 0 {
return msg, nil
}
// ignore what we don't want
if msg.typ != msgType {
log.Debugf("Tunnel received non %s message in waiting for %s", msg.typ, msgType)
continue
}
// got the message
return msg, nil
default:
// non blocking
}
return nil, io.EOF return nil, io.EOF
} }
} }