From d03b153e0984853d28716206053ff21ad285af69 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 25 Aug 2020 18:42:57 +0300 Subject: [PATCH] [#13] object/grpc: Fix Put call implementation Signed-off-by: Leonard Lyubich --- pkg/network/transport/object/grpc/service.go | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/network/transport/object/grpc/service.go b/pkg/network/transport/object/grpc/service.go index 43245d3df..20bb844f2 100644 --- a/pkg/network/transport/object/grpc/service.go +++ b/pkg/network/transport/object/grpc/service.go @@ -57,22 +57,22 @@ func (s *Server) Put(gStream objectGRPC.ObjectService_PutServer) error { for { req, err := gStream.Recv() - if err == nil { - if err := stream.Send(object.PutRequestFromGRPCMessage(req)); err != nil { - return err - } - } + if err != nil { + if errors.Is(errors.Cause(err), io.EOF) { + resp, err := stream.CloseAndRecv() + if err != nil { + return err + } - if errors.Is(errors.Cause(err), io.EOF) { - resp, err := stream.CloseAndRecv() - if err != nil { - return err + return gStream.SendAndClose(object.PutResponseToGRPCMessage(resp)) } - return gStream.SendAndClose(object.PutResponseToGRPCMessage(resp)) + return err } - return err + if err := stream.Send(object.PutRequestFromGRPCMessage(req)); err != nil { + return err + } } }