summaryrefslogtreecommitdiff
path: root/libgo/go
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2012-10-26 17:50:10 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2012-10-26 17:50:10 +0000
commit8bd4cb0808e21b288e4c85baf090372f4fe25b17 (patch)
treede04d5291829d3f364a180607a01c072cc985bb6 /libgo/go
parenta4a5a77adfc9c28d6963e5ae054c997d57cfc7fa (diff)
downloadgcc-8bd4cb0808e21b288e4c85baf090372f4fe25b17.tar.gz
syscall: fix creds_test to reliably close os.File
Uncovered by Uros Bizjak. Before this patch the test would close the file descriptor but not the os.File. When the os.File was GC'ed, the finalizer would close the file descriptor again. That would cause problems if the same file descriptor were returned by a later call to open in another test. On my system: > GOGC=30 go test --- FAIL: TestPassFD (0.04 seconds) passfd_test.go:62: FileConn: dup: bad file descriptor FAIL git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@192854 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go')
-rw-r--r--libgo/go/syscall/creds_test.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/libgo/go/syscall/creds_test.go b/libgo/go/syscall/creds_test.go
index 6eaa97e57b8..b1894c66b07 100644
--- a/libgo/go/syscall/creds_test.go
+++ b/libgo/go/syscall/creds_test.go
@@ -31,14 +31,18 @@ func TestSCMCredentials(t *testing.T) {
t.Fatalf("SetsockoptInt: %v", err)
}
- srv, err := net.FileConn(os.NewFile(uintptr(fds[0]), ""))
+ srvFile := os.NewFile(uintptr(fds[0]), "server")
+ defer srvFile.Close()
+ srv, err := net.FileConn(srvFile)
if err != nil {
t.Errorf("FileConn: %v", err)
return
}
defer srv.Close()
- cli, err := net.FileConn(os.NewFile(uintptr(fds[1]), ""))
+ cliFile := os.NewFile(uintptr(fds[1]), "client")
+ defer cliFile.Close()
+ cli, err := net.FileConn(cliFile)
if err != nil {
t.Errorf("FileConn: %v", err)
return