mirror of
https://github.com/golang/go
synced 2024-11-23 19:10:02 -07:00
http: make Transport warning about connections closing more accurate
It was fragile and non-portable, and then became spammy with the os.EINVAL removal. Now it just uses the length of the Peek return value instead. R=golang-dev, alex.brainman CC=golang-dev https://golang.org/cl/5453065
This commit is contained in:
parent
554ac03637
commit
130e2943a3
@ -21,9 +21,4 @@ GOFILES=\
|
||||
transfer.go\
|
||||
transport.go\
|
||||
|
||||
GOFILES_windows=\
|
||||
transport_windows.go\
|
||||
|
||||
GOFILES+=$(GOFILES_$(GOOS))
|
||||
|
||||
include ../../../Make.pkg
|
||||
|
@ -519,17 +519,11 @@ func (pc *persistConn) readLoop() {
|
||||
|
||||
for alive {
|
||||
pb, err := pc.br.Peek(1)
|
||||
if err != nil {
|
||||
if remoteSideClosed(err) && !pc.expectingResponse() {
|
||||
// Remote side closed on us. (We probably hit their
|
||||
// max idle timeout)
|
||||
pc.close()
|
||||
return
|
||||
}
|
||||
}
|
||||
if !pc.expectingResponse() {
|
||||
log.Printf("Unsolicited response received on idle HTTP channel starting with %q; err=%v",
|
||||
string(pb), err)
|
||||
if len(pb) > 0 {
|
||||
log.Printf("Unsolicited response received on idle HTTP channel starting with %q; err=%v",
|
||||
string(pb), err)
|
||||
}
|
||||
pc.close()
|
||||
return
|
||||
}
|
||||
|
@ -1,21 +0,0 @@
|
||||
// Copyright 2011 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package http
|
||||
|
||||
import (
|
||||
"net"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func init() {
|
||||
remoteSideClosedFunc = func(err error) (out bool) {
|
||||
op, ok := err.(*net.OpError)
|
||||
if ok && op.Op == "WSARecv" && op.Net == "tcp" && op.Err == syscall.Errno(10058) {
|
||||
// TODO(brainman,rsc): Fix whatever is generating this.
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user