From 12af62f25e35a85db5c319ea518d947f3d2d1783 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Wed, 25 Feb 2015 08:52:49 +0900 Subject: server: handle closed passiveConnCh channel When a peer is deleted, passiveConnCh is closed implicitly. Signed-off-by: FUJITA Tomonori --- server/fsm.go | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/server/fsm.go b/server/fsm.go index 26f7b830..bac2a956 100644 --- a/server/fsm.go +++ b/server/fsm.go @@ -211,7 +211,10 @@ func (h *FSMHandler) idle() bgp.FSMState { select { case <-h.t.Dying(): return 0 - case conn := <-fsm.passiveConnCh: + case conn, ok := <-fsm.passiveConnCh: + if !ok { + break + } conn.Close() log.WithFields(log.Fields{ "Topic": "Peer", @@ -255,7 +258,10 @@ func (h *FSMHandler) active() bgp.FSMState { select { case <-h.t.Dying(): return 0 - case conn := <-fsm.passiveConnCh: + case conn, ok := <-fsm.passiveConnCh: + if !ok { + break + } fsm.passiveConn = conn // we don't implement delayed open timer so move to opensent right // away. @@ -407,7 +413,10 @@ func (h *FSMHandler) opensent() bgp.FSMState { case <-h.t.Dying(): h.conn.Close() return 0 - case conn := <-fsm.passiveConnCh: + case conn, ok := <-fsm.passiveConnCh: + if !ok { + break + } conn.Close() log.WithFields(log.Fields{ "Topic": "Peer", @@ -502,7 +511,10 @@ func (h *FSMHandler) openconfirm() bgp.FSMState { case <-h.t.Dying(): h.conn.Close() return 0 - case conn := <-fsm.passiveConnCh: + case conn, ok := <-fsm.passiveConnCh: + if !ok { + break + } conn.Close() log.WithFields(log.Fields{ "Topic": "Peer", @@ -644,7 +656,10 @@ func (h *FSMHandler) established() bgp.FSMState { select { case <-h.t.Dying(): return 0 - case conn := <-fsm.passiveConnCh: + case conn, ok := <-fsm.passiveConnCh: + if !ok { + break + } conn.Close() log.WithFields(log.Fields{ "Topic": "Peer", -- cgit v1.2.3