summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--api/gobgp.pb.go12
-rw-r--r--api/gobgp.proto2
-rw-r--r--gobgp/global.go2
-rw-r--r--gomrt/main.go20
-rw-r--r--server/grpc_server.go15
5 files changed, 26 insertions, 25 deletions
diff --git a/api/gobgp.pb.go b/api/gobgp.pb.go
index 060aaa68..7d01de14 100644
--- a/api/gobgp.pb.go
+++ b/api/gobgp.pb.go
@@ -1384,7 +1384,7 @@ func (c *grpcClient) ModPath(ctx context.Context, opts ...grpc.CallOption) (Grpc
type Grpc_ModPathClient interface {
Send(*ModPathArguments) error
- Recv() (*Error, error)
+ CloseAndRecv() (*Error, error)
grpc.ClientStream
}
@@ -1396,7 +1396,10 @@ func (x *grpcModPathClient) Send(m *ModPathArguments) error {
return x.ClientStream.SendMsg(m)
}
-func (x *grpcModPathClient) Recv() (*Error, error) {
+func (x *grpcModPathClient) CloseAndRecv() (*Error, error) {
+ if err := x.ClientStream.CloseSend(); err != nil {
+ return nil, err
+ }
m := new(Error)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
@@ -1706,7 +1709,7 @@ func _Grpc_ModPath_Handler(srv interface{}, stream grpc.ServerStream) error {
}
type Grpc_ModPathServer interface {
- Send(*Error) error
+ SendAndClose(*Error) error
Recv() (*ModPathArguments, error)
grpc.ServerStream
}
@@ -1715,7 +1718,7 @@ type grpcModPathServer struct {
grpc.ServerStream
}
-func (x *grpcModPathServer) Send(m *Error) error {
+func (x *grpcModPathServer) SendAndClose(m *Error) error {
return x.ServerStream.SendMsg(m)
}
@@ -1888,7 +1891,6 @@ var _Grpc_serviceDesc = grpc.ServiceDesc{
{
StreamName: "ModPath",
Handler: _Grpc_ModPath_Handler,
- ServerStreams: true,
ClientStreams: true,
},
{
diff --git a/api/gobgp.proto b/api/gobgp.proto
index b4beb1c2..e54eacca 100644
--- a/api/gobgp.proto
+++ b/api/gobgp.proto
@@ -31,7 +31,7 @@ service Grpc {
rpc Shutdown(Arguments) returns (Error) {}
rpc Enable(Arguments) returns (Error) {}
rpc Disable(Arguments) returns (Error) {}
- rpc ModPath(stream ModPathArguments) returns (stream Error) {}
+ rpc ModPath(stream ModPathArguments) returns (Error) {}
rpc GetNeighborPolicy(Arguments) returns (ApplyPolicy) {}
rpc ModNeighborPolicy(stream PolicyArguments) returns (stream Error) {}
rpc GetPolicyRoutePolicies(PolicyArguments) returns (stream PolicyDefinition) {}
diff --git a/gobgp/global.go b/gobgp/global.go
index 7883c34a..b5f19ad3 100644
--- a/gobgp/global.go
+++ b/gobgp/global.go
@@ -190,7 +190,7 @@ func modPath(modtype string, eArgs []string) error {
}
stream.CloseSend()
- res, e := stream.Recv()
+ res, e := stream.CloseAndRecv()
if e != nil {
return e
}
diff --git a/gomrt/main.go b/gomrt/main.go
index e587df78..1e44737f 100644
--- a/gomrt/main.go
+++ b/gomrt/main.go
@@ -141,15 +141,6 @@ func main() {
os.Exit(1)
}
- res, err := stream.Recv()
- if err != nil {
- fmt.Println("failed to send:", err)
- os.Exit(1)
- }
- if res.Code != api.Error_SUCCESS {
- fmt.Errorf("error: code: %d, msg: %s", res.Code, res.Msg)
- os.Exit(1)
- }
}
idx += 1
@@ -158,6 +149,17 @@ func main() {
break
}
}
+
+ res, err := stream.CloseAndRecv()
+ if err != nil {
+ fmt.Println("failed to send:", err)
+ os.Exit(1)
+ }
+ if res.Code != api.Error_SUCCESS {
+ fmt.Errorf("error: code: %d, msg: %s", res.Code, res.Msg)
+ os.Exit(1)
+ }
+
},
}
diff --git a/server/grpc_server.go b/server/grpc_server.go
index ef850dbf..b14845b2 100644
--- a/server/grpc_server.go
+++ b/server/grpc_server.go
@@ -256,7 +256,7 @@ func (s *Server) ModPath(stream api.Grpc_ModPathServer) error {
arg, err := stream.Recv()
if err == io.EOF {
- return nil
+ break
} else if err != nil {
return err
}
@@ -282,15 +282,12 @@ func (s *Server) ModPath(stream api.Grpc_ModPathServer) error {
log.Debug(err.Error())
return err
}
-
- err = stream.Send(&api.Error{
- Code: api.Error_SUCCESS,
- })
-
- if err != nil {
- return err
- }
}
+ err := stream.SendAndClose(&api.Error{
+ Code: api.Error_SUCCESS,
+ })
+
+ return err
}
func (s *Server) GetNeighborPolicy(ctx context.Context, arg *api.Arguments) (*api.ApplyPolicy, error) {