client close: rpc: unable to write error response

when client close notice: "rpc: unable to write error response..."
This commit is contained in:
kuangzhiqiang 2019-02-03 19:12:13 +08:00 committed by GitHub
parent 89014160fc
commit 6be205fd40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -157,15 +157,17 @@ func (s *rpcServer) ServeConn(sock transport.Socket) {
// TODO: handle error better
if err := handler(ctx, request, response); err != nil {
// write an error response
err = rcodec.Write(&codec.Message{
Header: msg.Header,
Error: err.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 err != lastStreamResponseError {
// write an error response
err = rcodec.Write(&codec.Message{
Header: msg.Header,
Error: err.Error(),
Type: codec.Error,
}, nil)
// could not write the error response
if err != nil {
log.Logf("rpc: unable to write error response: %v", err)
}
}
s.wg.Done()
return