diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-05-20 03:50:40 +0000 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-05-20 05:47:11 +0000 |
commit | c2a0e730ec4fa7354388a178b9e54ad94b0c22ba (patch) | |
tree | ac641095d79aa6c1c5aef8a2fe3ba41fde116bde /server | |
parent | 2e2d67c967a4a03936ede9c474a8d42739215271 (diff) |
server: fix connectLoop() goroutine leak
While Connect() is proceeding, fsm can be stopped administratively.
In this case, after success of Connect(), no one is reading fsm.connCh,
so connectLoop() goroutine can be leaked. This commit fix this issue.
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r-- | server/fsm.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/server/fsm.go b/server/fsm.go index d70d0f8b..0c3c2efb 100644 --- a/server/fsm.go +++ b/server/fsm.go @@ -325,7 +325,15 @@ func (fsm *FSM) connectLoop() error { } if err == nil { - fsm.connCh <- conn + select { + case fsm.connCh <- conn: + default: + conn.Close() + log.WithFields(log.Fields{ + "Topic": "Peer", + "Key": fsm.pConf.Config.NeighborAddress, + }).Warn("active conn is closed to avoid being blocked") + } } else { log.WithFields(log.Fields{ "Topic": "Peer", |