fix some potential go routine leaks

This commit is contained in:
Asim Aslam 2019-12-08 15:02:54 +00:00
parent d28a868e46
commit 6064e1426c
2 changed files with 7 additions and 10 deletions

View File

@ -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:

View File

@ -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: