From f3b723ca442c54ad9e161ea3262f0d60655d5013 Mon Sep 17 00:00:00 2001 From: Richard Lindhout Date: Fri, 27 Sep 2019 15:02:21 +0200 Subject: [PATCH 1/2] Do nog log error when EOS is being written on an EOF socket --- server/rpc_server.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/server/rpc_server.go b/server/rpc_server.go index 43c4bae5..fcef3670 100644 --- a/server/rpc_server.go +++ b/server/rpc_server.go @@ -300,17 +300,21 @@ func (s *rpcServer) ServeConn(sock transport.Socket) { defer psock.Close() // serve the actual request using the request router - if err := r.ServeRequest(ctx, request, response); err != nil { + if serveRequestError := r.ServeRequest(ctx, request, response); serveRequestError != nil { // write an error response - err = rcodec.Write(&codec.Message{ + writeError := rcodec.Write(&codec.Message{ Header: msg.Header, - Error: err.Error(), + Error: serveRequestError.Error(), Type: codec.Error, }, nil) - // could not write the error response - if err != nil { - log.Logf("rpc: unable to write error response: %v", err) + // if the server request is an EOS error we let the socket know + // sometimes the socket is already closed on the other side, so we can ignore that error + alreadyClosed := serveRequestError == lastStreamResponseError && writeError == io.EOF + + // could not write error response + if writeError != nil && !alreadyClosed { + log.Logf("rpc: unable to write error response: %v", writeError) } } From a725998c0aa75edd594baea8cc7d4d34b5937f7e Mon Sep 17 00:00:00 2001 From: Richard Lindhout Date: Fri, 27 Sep 2019 16:01:16 +0200 Subject: [PATCH 2/2] Update rpc_server.go --- server/rpc_server.go | 1 + 1 file changed, 1 insertion(+) diff --git a/server/rpc_server.go b/server/rpc_server.go index fcef3670..89d60f9e 100644 --- a/server/rpc_server.go +++ b/server/rpc_server.go @@ -3,6 +3,7 @@ package server import ( "context" "fmt" + "io" "net" "runtime/debug" "sort"