mirror of
https://github.com/go-micro/go-micro.git
synced 2024-12-24 10:07:04 +02:00
fix some potential go routine leaks
This commit is contained in:
parent
d28a868e46
commit
6064e1426c
@ -1145,8 +1145,6 @@ func (n *network) connect() {
|
||||
n.sendConnect()
|
||||
}
|
||||
|
||||
log.Tracef("connected %v discovered %v backoff %v\n", connected, discovered, backoff.Do(attempts))
|
||||
|
||||
// check if we've been discovered
|
||||
select {
|
||||
case <-n.discovered:
|
||||
|
@ -200,6 +200,8 @@ func (l *link) process() {
|
||||
// process link state message
|
||||
select {
|
||||
case l.state <- pk:
|
||||
case <-l.closed:
|
||||
return
|
||||
default:
|
||||
}
|
||||
continue
|
||||
@ -221,7 +223,11 @@ func (l *link) process() {
|
||||
select {
|
||||
case pk := <-l.sendQueue:
|
||||
// send the message
|
||||
pk.status <- l.send(pk.message)
|
||||
select {
|
||||
case pk.status <- l.send(pk.message):
|
||||
case <-l.closed:
|
||||
return
|
||||
}
|
||||
case <-l.closed:
|
||||
return
|
||||
}
|
||||
@ -388,13 +394,6 @@ func (l *link) Send(m *transport.Message) error {
|
||||
// get time now
|
||||
now := time.Now()
|
||||
|
||||
// check if its closed first
|
||||
select {
|
||||
case <-l.closed:
|
||||
return io.EOF
|
||||
default:
|
||||
}
|
||||
|
||||
// queue the message
|
||||
select {
|
||||
case l.sendQueue <- p:
|
||||
|
Loading…
Reference in New Issue
Block a user