diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-06-21 10:57:28 +0900 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-06-21 10:58:00 +0900 |
commit | 706ccc9d71b3bd7b0555bf657dc80268b79222df (patch) | |
tree | 6629d100f6d7c81acb41fc7e9893ba4f5fb4eae1 /server/grpc_server.go | |
parent | 116ca18c598de459d09e7f64d19f61e53a900f75 (diff) |
api: change ModPath() return value to Error from stream Error
cut useless grpc communication and improve performance
simple performance test result.
rib.20150617.2000 is taken from http://archive.routeviews.org/
[before]
$ time gomrt -i rib.20150617.2000
gomrt -i /vagrant/rib.20150617.2000 45.96s user 171.73s system 86% cpu
4:11.87 total
[after]
$ time gomrt -i rib.20150617.2000
gomrt -i /vagrant/rib.20150617.2000 11.95s user 76.17s system 74% cpu
1:58.38 total
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server/grpc_server.go')
-rw-r--r-- | server/grpc_server.go | 15 |
1 files changed, 6 insertions, 9 deletions
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) { |