mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-27 12:38:11 +00:00
proxy: fix handling of CloseRead/CloseWrite for TCP port proxy
Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
parent
7219b18964
commit
a9fa07fd73
@ -3,7 +3,6 @@ package libproxy
|
|||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"syscall"
|
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
)
|
)
|
||||||
@ -47,13 +46,16 @@ func HandleTCPConnection(client Conn, backendAddr *net.TCPAddr, quit chan bool)
|
|||||||
var broker = func(to, from Conn) {
|
var broker = func(to, from Conn) {
|
||||||
written, err := io.Copy(to, from)
|
written, err := io.Copy(to, from)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// If the socket we are writing to is shutdown with
|
logrus.Println("error copying:", err)
|
||||||
// SHUT_WR, forward it to the other end of the pipe:
|
|
||||||
if err, ok := err.(*net.OpError); ok && err.Err == syscall.EPIPE {
|
|
||||||
from.CloseWrite()
|
|
||||||
}
|
}
|
||||||
|
err = from.CloseRead()
|
||||||
|
if err != nil {
|
||||||
|
logrus.Println("error CloseRead from:", err)
|
||||||
|
}
|
||||||
|
err = to.CloseWrite()
|
||||||
|
if err != nil {
|
||||||
|
logrus.Println("error CloseWrite to:", err)
|
||||||
}
|
}
|
||||||
to.CloseRead()
|
|
||||||
event <- written
|
event <- written
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user