From 706ccc9d71b3bd7b0555bf657dc80268b79222df Mon Sep 17 00:00:00 2001 From: ISHIDA Wataru Date: Sun, 21 Jun 2015 10:57:28 +0900 Subject: 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 --- server/grpc_server.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'server') 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) { -- cgit v1.2.3