From c2047754c300b68c05d65faa8dc2925fe67b71b4 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Sat, 14 Jan 2017 00:05:42 +0000 Subject: libgo: update to Go 1.8 release candidate 1 Compiler changes: * Change map assignment to use mapassign and assign value directly. * Change string iteration to use decoderune, faster for ASCII strings. * Change makeslice to take int, and use makeslice64 for larger values. * Add new noverflow field to hmap struct used for maps. Unresolved problems, to be fixed later: * Commented out test in go/types/sizes_test.go that doesn't compile. * Commented out reflect.TestStructOf test for padding after zero-sized field. Reviewed-on: https://go-review.googlesource.com/35231 gotools/: Updates for Go 1.8rc1. * Makefile.am (go_cmd_go_files): Add bug.go. (s-zdefaultcc): Write defaultPkgConfig. * Makefile.in: Rebuild. From-SVN: r244456 --- libgo/go/net/unixsock_posix.go | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'libgo/go/net/unixsock_posix.go') diff --git a/libgo/go/net/unixsock_posix.go b/libgo/go/net/unixsock_posix.go index 5f0999c..a8f892e 100644 --- a/libgo/go/net/unixsock_posix.go +++ b/libgo/go/net/unixsock_posix.go @@ -94,6 +94,10 @@ func (a *UnixAddr) sockaddr(family int) (syscall.Sockaddr, error) { return &syscall.SockaddrUnix{Name: a.Name}, nil } +func (a *UnixAddr) toLocal(net string) sockaddr { + return a +} + func (c *UnixConn) readFrom(b []byte) (int, *UnixAddr, error) { var addr *UnixAddr n, sa, err := c.fd.readFrom(b) @@ -173,9 +177,12 @@ func (ln *UnixListener) close() error { // is at least compatible with the auto-remove // sequence in ListenUnix. It's only non-Go // programs that can mess us up. - if ln.path[0] != '@' && ln.unlink { - syscall.Unlink(ln.path) - } + // Even if there are racy calls to Close, we want to unlink only for the first one. + ln.unlinkOnce.Do(func() { + if ln.path[0] != '@' && ln.unlink { + syscall.Unlink(ln.path) + } + }) return ln.fd.Close() } @@ -187,6 +194,18 @@ func (ln *UnixListener) file() (*os.File, error) { return f, nil } +// SetUnlinkOnClose sets whether the underlying socket file should be removed +// from the file system when the listener is closed. +// +// The default behavior is to unlink the socket file only when package net created it. +// That is, when the listener and the underlying socket file were created by a call to +// Listen or ListenUnix, then by default closing the listener will remove the socket file. +// but if the listener was created by a call to FileListener to use an already existing +// socket file, then by default closing the listener will not remove the socket file. +func (l *UnixListener) SetUnlinkOnClose(unlink bool) { + l.unlink = unlink +} + func listenUnix(ctx context.Context, network string, laddr *UnixAddr) (*UnixListener, error) { fd, err := unixSocket(ctx, network, laddr, nil, "listen") if err != nil { -- cgit v1.1