Skip to content

net/http: Shutdown may lose an active connection #33313

Closed
@monkey92t

Description

@monkey92t

What version of Go are you using (go version)?

go version go1.12.4 darwin/amd64

Does this issue reproduce with the latest release?

yes go 1.12

What operating system and processor architecture are you using (go env)?

go env Output
GOARCH="amd64"
GOBIN="/usr/local/go/bin"
GOCACHE="/var/root/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/var/root/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/ax/Desktop/ArcTestHttpServer/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build931930631=/tmp/go-build -gno-record-gcc-switches -fno-common"

my english is not very good. I try to describe it.

i found a problem in http shutdown(), when the shutdown function is executed, srv.mu.Lock() is executed. but at this time the net accept function can still be executed normally, execute c.setState(c.rwc, StateNew) put a new connection into activeConn and wait for srv.mu.Unlock().

when shutdown() finishes processing all activeConn connections, it will execute srv.mu.Unlock() and end the shutdown function, c.setState() gets the lock and puts a new connection into activeConn. At this point, there will still be an active connection after the shutdown() is completed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions