From 130e2943a320f012757518787b0c9dbf182ecb3a Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 6 Dec 2011 16:38:02 -0800 Subject: [PATCH] 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 --- src/pkg/net/http/Makefile | 5 ----- src/pkg/net/http/transport.go | 14 ++++---------- src/pkg/net/http/transport_windows.go | 21 --------------------- 3 files changed, 4 insertions(+), 36 deletions(-) delete mode 100644 src/pkg/net/http/transport_windows.go diff --git a/src/pkg/net/http/Makefile b/src/pkg/net/http/Makefile index 4bf33a629d4..807bc32447c 100644 --- a/src/pkg/net/http/Makefile +++ b/src/pkg/net/http/Makefile @@ -21,9 +21,4 @@ GOFILES=\ transfer.go\ transport.go\ -GOFILES_windows=\ - transport_windows.go\ - -GOFILES+=$(GOFILES_$(GOOS)) - include ../../../Make.pkg diff --git a/src/pkg/net/http/transport.go b/src/pkg/net/http/transport.go index e622e41f0a2..dc70be43f2d 100644 --- a/src/pkg/net/http/transport.go +++ b/src/pkg/net/http/transport.go @@ -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 } diff --git a/src/pkg/net/http/transport_windows.go b/src/pkg/net/http/transport_windows.go deleted file mode 100644 index c9ef2c2ab6e..00000000000 --- a/src/pkg/net/http/transport_windows.go +++ /dev/null @@ -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 - } -}