ignore write error for closed connection
This commit is contained in:
parent
0d996d7415
commit
7a618f4228
2 changed files with 8 additions and 19 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
"encoding/json"
|
||||
"io"
|
||||
"net"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/lbryio/reflector.go/reflector"
|
||||
|
@ -134,20 +135,6 @@ func (s *Server) handleConnection(conn net.Conn) {
|
|||
log.Error(errors.FullTrace(err))
|
||||
}
|
||||
|
||||
//if strings.Contains(string(request), `"requested_blobs"`) {
|
||||
// log.Debugln("received availability request")
|
||||
// response, err = s.handleAvailabilityRequest(request)
|
||||
//} else if strings.Contains(string(request), `"blob_data_payment_rate"`) {
|
||||
// log.Debugln("received rate negotiation request")
|
||||
// response, err = s.handlePaymentRateNegotiation(request)
|
||||
//} else if strings.Contains(string(request), `"requested_blob"`) {
|
||||
// log.Debugln("received blob request")
|
||||
// response, err = s.handleBlobRequest(request)
|
||||
//} else {
|
||||
// log.Errorln("invalid request")
|
||||
// spew.Dump(request)
|
||||
// return
|
||||
//}
|
||||
response, err = s.handleCompositeRequest(request)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
|
@ -161,7 +148,9 @@ func (s *Server) handleConnection(conn net.Conn) {
|
|||
|
||||
n, err := conn.Write(response)
|
||||
if err != nil {
|
||||
s.logError(err)
|
||||
if !strings.Contains(err.Error(), "connection reset by peer") { // means the other side closed the connection using TCP reset
|
||||
s.logError(err)
|
||||
}
|
||||
return
|
||||
} else if n != len(response) {
|
||||
log.Errorln(io.ErrShortWrite)
|
||||
|
|
|
@ -73,13 +73,13 @@ func (s *Stats) AddError(e error) (shouldLog bool) { // shouldLog is a hack, but
|
|||
}
|
||||
err := errors.Wrap(e, 0)
|
||||
name := err.TypeName()
|
||||
if strings.Contains(err.Error(), "i/o timeout") {
|
||||
if strings.Contains(err.Error(), "i/o timeout") { // hit a read or write deadline
|
||||
name = "i/o timeout"
|
||||
} else if strings.Contains(err.Error(), "read: connection reset by peer") {
|
||||
} else if strings.Contains(err.Error(), "read: connection reset by peer") { // the other side closed the connection using TCP reset
|
||||
name = "read conn reset"
|
||||
} else if strings.Contains(err.Error(), "unexpected EOF") {
|
||||
} else if strings.Contains(err.Error(), "unexpected EOF") { // tried to read from closed pipe or socket
|
||||
name = "unexpected EOF"
|
||||
} else if strings.Contains(err.Error(), "write: broken pipe") {
|
||||
} else if strings.Contains(err.Error(), "write: broken pipe") { // tried to write to a pipe or socket that was closed by the peer
|
||||
name = "write broken pipe"
|
||||
} else {
|
||||
shouldLog = true
|
||||
|
|
Loading…
Reference in a new issue