mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
proxy: clean up code (addendum to #1598)
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
This commit is contained in:
parent
da6c6baa92
commit
d3e7ca726d
1 changed files with 1 additions and 8 deletions
|
@ -5,7 +5,6 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// TCPProxy is a proxy for TCP connections. It implements the Proxy interface to
|
// TCPProxy is a proxy for TCP connections. It implements the Proxy interface to
|
||||||
|
@ -41,13 +40,7 @@ func (proxy *TCPProxy) clientLoop(client *net.TCPConn, quit chan bool) {
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
var broker = func(to, from *net.TCPConn) {
|
var broker = func(to, from *net.TCPConn) {
|
||||||
if _, err := io.Copy(to, from); err != nil {
|
io.Copy(to, from)
|
||||||
// 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 {
|
|
||||||
from.CloseWrite()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
from.CloseRead()
|
from.CloseRead()
|
||||||
to.CloseWrite()
|
to.CloseWrite()
|
||||||
wg.Done()
|
wg.Done()
|
||||||
|
|
Loading…
Reference in a new issue