summaryrefslogtreecommitdiffhomepage
path: root/server/server.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-07-26 22:17:15 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-07-27 09:13:52 +0900
commitf8c2ebb03df53bb0d45cb36277a883420fa6b9a2 (patch)
tree9af18fabd036b316671cff1fd7c506787c54ff27 /server/server.go
parent2721daa0d8141a75176dbccdb7736327aea9484c (diff)
server: only the maing goroutine can call Shutdown()
s.neighborMap needs to be protected. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/server.go')
-rw-r--r--server/server.go17
1 files changed, 12 insertions, 5 deletions
diff --git a/server/server.go b/server/server.go
index 0fc661f5..15bd90de 100644
--- a/server/server.go
+++ b/server/server.go
@@ -903,12 +903,19 @@ func (s *BgpServer) DeleteBmp(c *config.BmpServerConfig) (err error) {
return err
}
-func (server *BgpServer) Shutdown() {
- server.shutdown = true
- for _, p := range server.neighborMap {
- p.fsm.adminStateCh <- ADMIN_STATE_DOWN
+func (s *BgpServer) Shutdown() {
+ ch := make(chan struct{})
+ defer func() { <-ch }()
+
+ s.mgmtCh <- func() {
+ defer close(ch)
+
+ s.shutdown = true
+ for _, p := range s.neighborMap {
+ p.fsm.adminStateCh <- ADMIN_STATE_DOWN
+ }
+ // TODO: call fsmincomingCh.Close()
}
- // TODO: call fsmincomingCh.Close()
}
func (s *BgpServer) UpdatePolicy(policy config.RoutingPolicy) (err error) {