net: UnixListener.Close can be dangerous #17131
Labels
Documentation
FrozenDueToAge
NeedsFix
The path to resolution is known, but the work has not been done.
Milestone
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version devel +7f583a4 Wed Sep 14 13:28:13 2016 +0000 linux/amd64
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH=""
GORACE=""
GOROOT="/home/moroz/go"
GOTOOLDIR="/home/moroz/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build862845019=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
What did you do?
Here is simple program which shows the problem:
https://gist.github.com/7595f6db11d7202cb3fa12e64a862c61
What did you expect to see?
UnixListener.Close() unlinks unix-socket only once.
What did you see instead?
UnixListener.Close() unconditionally unlinks unix-socket file - with closed listener you can unlink it again, Close will return an error, but file will be deleted anyway.
I've encountered this problem when worked with grpc, which supposed that it's safe to call Close() multiple times and actually I thought so, too.
I wonder if it's too bad to have sync.Once there.
Thanks!
The text was updated successfully, but these errors were encountered: