Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions proxy/proxy_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//go:build !windows

package proxy

import "syscall"

// errConnReset is the platform-specific "connection reset by peer".
const errConnReset = syscall.ECONNRESET
10 changes: 10 additions & 0 deletions proxy/proxy_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package proxy

import (
"syscall"
)

// errConnReset is the platform-specific "connection reset by peer".
//
// https://learn.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2#wsaeconnreset
const errConnReset = syscall.WSAECONNRESET
3 changes: 2 additions & 1 deletion proxy/tcp_proxy.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package proxy

import (
"errors"
"io"
"net"
"syscall"
Expand Down Expand Up @@ -51,7 +52,7 @@ func (proxy *TCPProxy) clientLoop(client *net.TCPConn, quit chan bool) {
if err != nil {
// If the socket we are writing to is shutdown with
// SHUT_WR, forward it to the other end of the pipe:
if err, ok := err.(*net.OpError); ok && err.Err == syscall.EPIPE {
if errors.Is(err, syscall.EPIPE) || errors.Is(err, errConnReset) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker-proxy seems to have its own version of this code.

Since https://github.com/moby/libnetwork/pull/1617/files, it just unconditionally closes the socket when io.Copy returns ... this should probably do the same?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point; looking at that PR, I see that change was made following another PR that made other changes - are those relevant for this? Perhaps @AkihiroSuda recalls / could look just to be sure;

_ = from.CloseRead()
}
}
Expand Down
Loading