diff options
Diffstat (limited to 'server/server.go')
-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 } |