net: only remove Unix domain socket file on the first call to Close

Fixes #17131.

Change-Id: I60b381687746fadce12ef18a190cbe3f435172f2
Reviewed-on: https://go-review.googlesource.com/32098
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Quentin Smith <quentin@golang.org>
This commit is contained in:
Russ Cox 2016-10-26 20:13:33 -04:00
parent 87e48c5afd
commit 13558c41ff
3 changed files with 23 additions and 6 deletions

View file

@ -7,6 +7,7 @@ package net
import (
"context"
"os"
"sync"
"syscall"
"time"
)
@ -206,9 +207,10 @@ func DialUnix(net string, laddr, raddr *UnixAddr) (*UnixConn, error) {
// typically use variables of type Listener instead of assuming Unix
// domain sockets.
type UnixListener struct {
fd *netFD
path string
unlink bool
fd *netFD
path string
unlink bool
unlinkOnce sync.Once
}
func (ln *UnixListener) ok() bool { return ln != nil && ln.fd != nil }