move gRPC-related code for REQ_GET_SERVER to grpc_server.go

Signed-off-by: FUJITA Tomonori <[email protected]>
This commit is contained in:
FUJITA Tomonori
2016-07-26 15:35:41 +09:00
parent 5aea2d93fd
commit e7354de8bb
2 changed files with 15 additions and 12 deletions
+2 -6
View File
@@ -1706,11 +1706,7 @@ func (s *Server) ReplacePolicyAssignment(ctx context.Context, arg *api.ReplacePo
}
func (s *Server) GetServer(ctx context.Context, arg *api.GetServerRequest) (*api.GetServerResponse, error) {
d, err := s.get(REQ_GET_SERVER, arg)
if err != nil {
return nil, err
}
g := d.(*config.Global)
g := s.bgpServer.GetServer()
return &api.GetServerResponse{
Global: &api.Global{
As: g.Config.As,
@@ -1720,7 +1716,7 @@ func (s *Server) GetServer(ctx context.Context, arg *api.GetServerRequest) (*api
MplsLabelMin: g.MplsLabelRange.MinLabel,
MplsLabelMax: g.MplsLabelRange.MaxLabel,
},
}, err
}, nil
}
func (s *Server) StartServer(ctx context.Context, arg *api.StartServerRequest) (*api.StartServerResponse, error) {
+13 -6
View File
@@ -1361,12 +1361,6 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) {
var err error
switch grpcReq.RequestType {
case REQ_GET_SERVER:
g := server.bgpConfig.Global
grpcReq.ResponseCh <- &GrpcResponse{
Data: &g,
}
close(grpcReq.ResponseCh)
case REQ_GLOBAL_RIB, REQ_LOCAL_RIB:
arg := grpcReq.Data.(*api.GetRibRequest)
rib := server.globalRib
@@ -1717,6 +1711,19 @@ ERROR:
return
}
func (s *BgpServer) GetServer() (c *config.Global) {
ch := make(chan struct{})
defer func() { <-ch }()
s.mgmtCh <- func() {
defer close(ch)
g := s.bgpConfig.Global
c = &g
}
return c
}
func (s *BgpServer) GetNeighbor() (l []*config.Neighbor) {
ch := make(chan struct{})
defer func() { <-ch }()