diff options
Diffstat (limited to 'src/internal/poll')
| -rw-r--r-- | src/internal/poll/fd_windows.go | 7 | ||||
| -rw-r--r-- | src/internal/poll/fd_windows_test.go | 2 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/internal/poll/fd_windows.go b/src/internal/poll/fd_windows.go index fe23d4b3d7..b08ca615c6 100644 --- a/src/internal/poll/fd_windows.go +++ b/src/internal/poll/fd_windows.go @@ -53,14 +53,17 @@ func checkSetFileCompletionNotificationModes() { useSetFileCompletionNotificationModes = true } -func init() { +// InitWSA initiates the use of the Winsock DLL by the current process. +// It is called from the net package at init time to avoid +// loading ws2_32.dll when net is not used. +var InitWSA = sync.OnceFunc(func() { var d syscall.WSAData e := syscall.WSAStartup(uint32(0x202), &d) if e != nil { initErr = e } checkSetFileCompletionNotificationModes() -} +}) // operation contains superset of data necessary to perform all async IO. type operation struct { diff --git a/src/internal/poll/fd_windows_test.go b/src/internal/poll/fd_windows_test.go index f0697a0d7b..1cee18dcba 100644 --- a/src/internal/poll/fd_windows_test.go +++ b/src/internal/poll/fd_windows_test.go @@ -41,6 +41,8 @@ func logFD(net string, fd *poll.FD, err error) { func init() { loggedFDs = make(map[syscall.Handle]*loggedFD) *poll.LogInitFD = logFD + + poll.InitWSA() } func findLoggedFD(h syscall.Handle) (lfd *loggedFD, found bool) { |
