]> Cypherpunks repositories - gostls13.git/commitdiff
net: remove sysSocket fallback for Windows 7
authorqmuntal <quimmuntal@gmail.com>
Mon, 26 Jun 2023 13:10:30 +0000 (15:10 +0200)
committerQuim Muntal <quimmuntal@gmail.com>
Thu, 20 Jul 2023 18:36:30 +0000 (18:36 +0000)
`syscall.ForkLock` is not used in `syscall.StartProcess` since
CL 288297, so using it in `sysSocket` makes no sense. This CL
goes a little bit further and removes the `sysSocket` fallback for
Windows 7, since it is not supported since go 1.21 (#57003).

Updates #60942

Change-Id: If14a0d94742f1b80af994f9f69938701ee41b402
Reviewed-on: https://go-review.googlesource.com/c/go/+/506136
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
src/net/hook_windows.go
src/net/internal/socktest/main_test.go
src/net/internal/socktest/main_windows_test.go [deleted file]
src/net/internal/socktest/sys_windows.go
src/net/main_windows_test.go
src/net/sock_windows.go
src/syscall/exec_windows.go

index ab8656cbbf343bdc6d720a7ce24d7a5f41172b7c..28c49cc6de7e7bcbaba710c9446759f8ce2677b9 100644 (file)
@@ -14,7 +14,6 @@ var (
        testHookDialChannel = func() { time.Sleep(time.Millisecond) } // see golang.org/issue/5349
 
        // Placeholders for socket system calls.
-       socketFunc    func(int, int, int) (syscall.Handle, error)                                                 = syscall.Socket
        wsaSocketFunc func(int32, int32, int32, *syscall.WSAProtocolInfo, uint32, uint32) (syscall.Handle, error) = windows.WSASocket
        connectFunc   func(syscall.Handle, syscall.Sockaddr) error                                                = syscall.Connect
        listenFunc    func(syscall.Handle, int) error                                                             = syscall.Listen
index 0197feb3f199aa72ee2e90e03ea9cf888deb6fd5..967ce6795aedb764f4830341dd8ed59a3c4a6265 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build !js && !plan9 && !wasip1
+//go:build !js && !plan9 && !wasip1 && !windows
 
 package socktest_test
 
diff --git a/src/net/internal/socktest/main_windows_test.go b/src/net/internal/socktest/main_windows_test.go
deleted file mode 100644 (file)
index df1cb97..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2015 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package socktest_test
-
-import "syscall"
-
-var (
-       socketFunc func(int, int, int) (syscall.Handle, error)
-       closeFunc  func(syscall.Handle) error
-)
-
-func installTestHooks() {
-       socketFunc = sw.Socket
-       closeFunc = sw.Closesocket
-}
-
-func uninstallTestHooks() {
-       socketFunc = syscall.Socket
-       closeFunc = syscall.Closesocket
-}
index 8c1c862f33c9bd6093dec58331f93c38b4dc4fcd..1c42e5c7f34b71da9c9590ab73678ba10a44b367 100644 (file)
@@ -9,38 +9,6 @@ import (
        "syscall"
 )
 
-// Socket wraps syscall.Socket.
-func (sw *Switch) Socket(family, sotype, proto int) (s syscall.Handle, err error) {
-       sw.once.Do(sw.init)
-
-       so := &Status{Cookie: cookie(family, sotype, proto)}
-       sw.fmu.RLock()
-       f, _ := sw.fltab[FilterSocket]
-       sw.fmu.RUnlock()
-
-       af, err := f.apply(so)
-       if err != nil {
-               return syscall.InvalidHandle, err
-       }
-       s, so.Err = syscall.Socket(family, sotype, proto)
-       if err = af.apply(so); err != nil {
-               if so.Err == nil {
-                       syscall.Closesocket(s)
-               }
-               return syscall.InvalidHandle, err
-       }
-
-       sw.smu.Lock()
-       defer sw.smu.Unlock()
-       if so.Err != nil {
-               sw.stats.getLocked(so.Cookie).OpenFailed++
-               return syscall.InvalidHandle, so.Err
-       }
-       nso := sw.addLocked(s, family, sotype, proto)
-       sw.stats.getLocked(nso.Cookie).Opened++
-       return s, nil
-}
-
 // WSASocket wraps syscall.WSASocket.
 func (sw *Switch) WSASocket(family, sotype, proto int32, protinfo *syscall.WSAProtocolInfo, group uint32, flags uint32) (s syscall.Handle, err error) {
        sw.once.Do(sw.init)
index 07f21b72eb1fcc9a57c352312721ce1c5b0a2190..bc024c0bbd82d01939bc0fd191739875a4423f4f 100644 (file)
@@ -8,7 +8,6 @@ import "internal/poll"
 
 var (
        // Placeholders for saving original socket system calls.
-       origSocket      = socketFunc
        origWSASocket   = wsaSocketFunc
        origClosesocket = poll.CloseFunc
        origConnect     = connectFunc
@@ -18,7 +17,6 @@ var (
 )
 
 func installTestHooks() {
-       socketFunc = sw.Socket
        wsaSocketFunc = sw.WSASocket
        poll.CloseFunc = sw.Closesocket
        connectFunc = sw.Connect
@@ -28,7 +26,6 @@ func installTestHooks() {
 }
 
 func uninstallTestHooks() {
-       socketFunc = origSocket
        wsaSocketFunc = origWSASocket
        poll.CloseFunc = origClosesocket
        connectFunc = origConnect
index fa11c7af2e727c21facca8c6daa2d7b3af9ba672..5540135a2c43eff525d96a6e157b792dd1589a6a 100644 (file)
@@ -19,21 +19,6 @@ func maxListenerBacklog() int {
 func sysSocket(family, sotype, proto int) (syscall.Handle, error) {
        s, err := wsaSocketFunc(int32(family), int32(sotype), int32(proto),
                nil, 0, windows.WSA_FLAG_OVERLAPPED|windows.WSA_FLAG_NO_HANDLE_INHERIT)
-       if err == nil {
-               return s, nil
-       }
-       // WSA_FLAG_NO_HANDLE_INHERIT flag is not supported on some
-       // old versions of Windows, see
-       // https://msdn.microsoft.com/en-us/library/windows/desktop/ms742212(v=vs.85).aspx
-       // for details. Just use syscall.Socket, if windows.WSASocket failed.
-
-       // See ../syscall/exec_unix.go for description of ForkLock.
-       syscall.ForkLock.RLock()
-       s, err = socketFunc(family, sotype, proto)
-       if err == nil {
-               syscall.CloseOnExec(s)
-       }
-       syscall.ForkLock.RUnlock()
        if err != nil {
                return syscall.InvalidHandle, os.NewSyscallError("socket", err)
        }
index 0a93bc0a80d4edd11a15ac5be57695cae0c3c7ac..06e684c7116b4f344430196abd3435d9a3013415 100644 (file)
@@ -14,6 +14,7 @@ import (
        "unsafe"
 )
 
+// ForkLock is not used on Windows.
 var ForkLock sync.RWMutex
 
 // EscapeArg rewrites command line argument s as prescribed