Move copyBytes closer to use-sites

pull/6/head
Tim Hockin 2014-09-20 11:31:13 -07:00
parent cf6ccaee54
commit 20826e6d50
1 changed files with 11 additions and 11 deletions

View File

@ -125,6 +125,17 @@ func proxyTCP(in, out *net.TCPConn) {
out.Close()
}
func copyBytes(in, out *net.TCPConn, wg *sync.WaitGroup) {
defer wg.Done()
glog.Infof("Copying from %v <-> %v <-> %v <-> %v",
in.RemoteAddr(), in.LocalAddr(), out.LocalAddr(), out.RemoteAddr())
if _, err := io.Copy(in, out); err != nil {
glog.Errorf("I/O error: %v", err)
}
in.CloseRead()
out.CloseWrite()
}
// udpProxySocket implements proxySocket. Close() is implemented by net.UDPConn. When Close() is called,
// no new connections are allowed and existing connections are broken.
// TODO: We could lame-duck this ourselves, if it becomes important.
@ -306,17 +317,6 @@ func NewProxier(loadBalancer LoadBalancer, address string) *Proxier {
}
}
func copyBytes(in, out *net.TCPConn, wg *sync.WaitGroup) {
defer wg.Done()
glog.Infof("Copying from %v <-> %v <-> %v <-> %v",
in.RemoteAddr(), in.LocalAddr(), out.LocalAddr(), out.RemoteAddr())
if _, err := io.Copy(in, out); err != nil {
glog.Errorf("I/O error: %v", err)
}
in.CloseRead()
out.CloseWrite()
}
// StopProxy stops the proxy for the named service.
func (proxier *Proxier) StopProxy(service string) error {
info, found := proxier.getServiceInfo(service)