summaryrefslogtreecommitdiffhomepage
path: root/server/server.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-07-26 11:57:55 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-07-26 11:57:55 +0900
commitf623f8d538cd0ce9b31a97248ac862bb1c8b8b7c (patch)
treed8fd8c23792c0248583836f38b6d0dc1eefb5028 /server/server.go
parent9b1dac34bb22f159babf352bf43d7e3ffdf157e5 (diff)
move gRPC-related code for REQ_STOP_SERVER to grpc_server.go
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/server.go')
-rw-r--r--server/server.go41
1 files changed, 21 insertions, 20 deletions
diff --git a/server/server.go b/server/server.go
index dc8ab200..6b15527a 100644
--- a/server/server.go
+++ b/server/server.go
@@ -1317,19 +1317,6 @@ func (server *BgpServer) handleModConfig(grpcReq *GrpcRequest) error {
c = &b.Global
case *config.Global:
c = arg
- case *api.StopServerRequest:
- for k, _ := range server.neighborMap {
- err := server.deleteNeighbor(&config.Neighbor{Config: config.NeighborConfig{
- NeighborAddress: k}}, bgp.BGP_ERROR_CEASE, bgp.BGP_ERROR_SUB_PEER_DECONFIGURED)
- if err != nil {
- return err
- }
- }
- for _, l := range server.listeners {
- l.Close()
- }
- server.bgpConfig.Global = config.Global{}
- return nil
}
if server.bgpConfig.Global.Config.As != 0 {
@@ -1362,6 +1349,27 @@ func (server *BgpServer) handleModConfig(grpcReq *GrpcRequest) error {
return nil
}
+func (s *BgpServer) Stop() (err error) {
+ ch := make(chan struct{})
+ defer func() { <-ch }()
+
+ s.mgmtCh <- func() {
+ defer close(ch)
+
+ for k, _ := range s.neighborMap {
+ if err = s.deleteNeighbor(&config.Neighbor{Config: config.NeighborConfig{
+ NeighborAddress: k}}, bgp.BGP_ERROR_CEASE, bgp.BGP_ERROR_SUB_PEER_DECONFIGURED); err != nil {
+ return
+ }
+ }
+ for _, l := range s.listeners {
+ l.Close()
+ }
+ s.bgpConfig.Global = config.Global{}
+ }
+ return nil
+}
+
func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) {
logOp := func(addr string, action string) {
log.WithFields(log.Fields{
@@ -1406,13 +1414,6 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) {
Data: &api.StartServerResponse{},
}
close(grpcReq.ResponseCh)
- case REQ_STOP_SERVER:
- err := server.handleModConfig(grpcReq)
- grpcReq.ResponseCh <- &GrpcResponse{
- ResponseErr: err,
- Data: &api.StopServerResponse{},
- }
- close(grpcReq.ResponseCh)
case REQ_GLOBAL_RIB, REQ_LOCAL_RIB:
arg := grpcReq.Data.(*api.GetRibRequest)
rib := server.globalRib