diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-11-12 11:02:11 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-12-15 12:06:40 +0900 |
commit | 38da8bb562086d98d0a56cbe23ae1568e8a66792 (patch) | |
tree | 7d7137314d88ac76d729bc419530a2dd891078f2 /server | |
parent | ac6af737a7733612acf293ec5eb4c21932aa0e5d (diff) |
server: ensure global config is finished before any other config
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r-- | server/server.go | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/server/server.go b/server/server.go index b1690aae..15e2a053 100644 --- a/server/server.go +++ b/server/server.go @@ -103,7 +103,7 @@ type BgpServer struct { func NewBgpServer(port int) *BgpServer { b := BgpServer{} - b.globalTypeCh = make(chan config.Global) + b.globalTypeCh = make(chan config.Global, 1) b.addedPeerCh = make(chan config.Neighbor) b.deletedPeerCh = make(chan config.Neighbor) b.updatedPeerCh = make(chan config.Neighbor) @@ -148,15 +148,23 @@ func (server *BgpServer) Serve() { var g config.Global for { select { - case grpcReq := <-server.GrpcReqCh: - server.handleGrpc(grpcReq) case g = <-server.globalTypeCh: server.bgpConfig.Global = g server.globalTypeCh = nil + default: } + if server.globalTypeCh == nil { break } + + select { + case grpcReq := <-server.GrpcReqCh: + server.handleGrpc(grpcReq) + case g = <-server.globalTypeCh: + server.bgpConfig.Global = g + server.globalTypeCh = nil + } } if g.Mrt.FileName != "" { @@ -1332,9 +1340,7 @@ func (server *BgpServer) handleModGlobalConfig(grpcReq *GrpcRequest) error { if err := server.SetRoutingPolicy(p); err != nil { log.Fatal(err) } - go func() { - server.globalTypeCh <- c.Global - }() + server.globalTypeCh <- c.Global return nil } |