From cd85e47be29ca4e27bbbb0853fb215a903827cd4 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Thu, 5 Oct 2017 14:36:36 +0900 Subject: server: stop Shutdown() with no peer After Shutdown() is called, the main goroutine waits for peers' goroutines to stop then dies. But if no peer is configured, the main goroutines never dies. Signed-off-by: FUJITA Tomonori --- server/server.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'server/server.go') diff --git a/server/server.go b/server/server.go index bb208846..03b9cbd2 100644 --- a/server/server.go +++ b/server/server.go @@ -1144,6 +1144,10 @@ func (s *BgpServer) Shutdown() { for _, p := range s.neighborMap { p.fsm.adminStateCh <- stateOp } + // the main goroutine waits for peers' goroutines to stop but if no peer is configured, needs to die immediately. + if len(s.neighborMap) == 0 { + os.Exit(0) + } // TODO: call fsmincomingCh.Close() return nil }, false) -- cgit v1.2.3