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()
|
n.sendConnect()
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Tracef("connected %v discovered %v backoff %v\n", connected, discovered, backoff.Do(attempts))
|
|
||||||
|
|
||||||
// check if we've been discovered
|
// check if we've been discovered
|
||||||
select {
|
select {
|
||||||
case <-n.discovered:
|
case <-n.discovered:
|
||||||
|
@ -200,6 +200,8 @@ func (l *link) process() {
|
|||||||
// process link state message
|
// process link state message
|
||||||
select {
|
select {
|
||||||
case l.state <- pk:
|
case l.state <- pk:
|
||||||
|
case <-l.closed:
|
||||||
|
return
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
@ -221,7 +223,11 @@ func (l *link) process() {
|
|||||||
select {
|
select {
|
||||||
case pk := <-l.sendQueue:
|
case pk := <-l.sendQueue:
|
||||||
// send the message
|
// send the message
|
||||||
pk.status <- l.send(pk.message)
|
select {
|
||||||
|
case pk.status <- l.send(pk.message):
|
||||||
|
case <-l.closed:
|
||||||
|
return
|
||||||
|
}
|
||||||
case <-l.closed:
|
case <-l.closed:
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -388,13 +394,6 @@ func (l *link) Send(m *transport.Message) error {
|
|||||||
// get time now
|
// get time now
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|
||||||
// check if its closed first
|
|
||||||
select {
|
|
||||||
case <-l.closed:
|
|
||||||
return io.EOF
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
|
|
||||||
// queue the message
|
// queue the message
|
||||||
select {
|
select {
|
||||||
case l.sendQueue <- p:
|
case l.sendQueue <- p:
|
||||||
|
Loading…
Reference in New Issue
Block a user