From 9490ede80452ce6e3b8df27e01f8baacfb0f155c Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 26 Jul 2021 16:26:06 +0200 Subject: [PATCH 1/2] Revert "sockets: defaultTimeout is unused on Windows (deadcode)" This reverts commit fcf9eb72347e4bfa9f9c64b557aaa0ac032c8f9c. Signed-off-by: Sebastiaan van Stijn --- sockets/sockets.go | 3 +++ sockets/sockets_unix.go | 5 +---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sockets/sockets.go b/sockets/sockets.go index 2e9e9006f..73ff9fcb7 100644 --- a/sockets/sockets.go +++ b/sockets/sockets.go @@ -4,8 +4,11 @@ package sockets import ( "errors" "net/http" + "time" ) +const defaultTimeout = 10 * time.Second + // ErrProtocolNotAvailable is returned when a given transport protocol is not provided by the operating system. var ErrProtocolNotAvailable = errors.New("protocol not available") diff --git a/sockets/sockets_unix.go b/sockets/sockets_unix.go index 10d763426..5b65c546a 100644 --- a/sockets/sockets_unix.go +++ b/sockets/sockets_unix.go @@ -11,10 +11,7 @@ import ( "time" ) -const ( - defaultTimeout = 10 * time.Second - maxUnixSocketPathSize = len(syscall.RawSockaddrUnix{}.Path) -) +const maxUnixSocketPathSize = len(syscall.RawSockaddrUnix{}.Path) func configureUnixTransport(tr *http.Transport, proto, addr string) error { if len(addr) > maxUnixSocketPathSize { From 65d248421485c0edf7b7e245d5d56df5fb71ce48 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 26 Jul 2021 16:26:24 +0200 Subject: [PATCH 2/2] Revert "configureNpipeTransport: use winio.DialPipeContext()" This reverts commit ad28c33c3ff6d85b87964574431f56227e29d9f8. Signed-off-by: Sebastiaan van Stijn --- sockets/sockets_windows.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sockets/sockets_windows.go b/sockets/sockets_windows.go index 7acafc5a2..16f8cdbb1 100644 --- a/sockets/sockets_windows.go +++ b/sockets/sockets_windows.go @@ -17,7 +17,12 @@ func configureNpipeTransport(tr *http.Transport, proto, addr string) error { // No need for compression in local communications. tr.DisableCompression = true tr.DialContext = func(ctx context.Context, _, _ string) (net.Conn, error) { - return winio.DialPipeContext(ctx, addr) + // DialPipeContext() has been added to winio: + // https://github.com/Microsoft/go-winio/commit/5fdbdcc2ae1c7e1073157fa7cb34a15eab472e1d + // However, a new version of winio with this commit has not been released yet. + // Continue to use DialPipe() until DialPipeContext() becomes available. + //return winio.DialPipeContext(ctx, addr) + return DialPipe(addr, defaultTimeout) } return nil }