Merge pull request #797 from RichardLindhout/patch-1
Do not log error when EOS is being written on an EOF socket
This commit is contained in:
commit
da572041ca
@ -3,6 +3,7 @@ package server
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"sort"
|
"sort"
|
||||||
@ -300,17 +301,21 @@ func (s *rpcServer) ServeConn(sock transport.Socket) {
|
|||||||
defer psock.Close()
|
defer psock.Close()
|
||||||
|
|
||||||
// serve the actual request using the request router
|
// 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
|
// write an error response
|
||||||
err = rcodec.Write(&codec.Message{
|
writeError := rcodec.Write(&codec.Message{
|
||||||
Header: msg.Header,
|
Header: msg.Header,
|
||||||
Error: err.Error(),
|
Error: serveRequestError.Error(),
|
||||||
Type: codec.Error,
|
Type: codec.Error,
|
||||||
}, nil)
|
}, nil)
|
||||||
|
|
||||||
// could not write the error response
|
// if the server request is an EOS error we let the socket know
|
||||||
if err != nil {
|
// sometimes the socket is already closed on the other side, so we can ignore that error
|
||||||
log.Logf("rpc: unable to write error response: %v", err)
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user