this might be all we need to ensure that we're cleaning up both sides when one side terminates (#305)

This commit is contained in:
Michael Quigley 2023-04-18 13:11:21 -04:00
parent c31a1cd464
commit 7c01f6d52a
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
2 changed files with 28 additions and 0 deletions

View File

@ -68,6 +68,9 @@ func (b *Backend) handle(conn net.Conn) {
}
func (b *Backend) rxer(conn, rConn net.Conn) {
logrus.Infof("started '%v' <=> '%v'", conn.RemoteAddr(), rConn.RemoteAddr())
defer logrus.Warnf("exited '%v' <=> '%v'", conn.RemoteAddr(), rConn.RemoteAddr())
buf := make([]byte, 10240)
for {
if rxsz, err := conn.Read(buf); err == nil {
@ -77,16 +80,23 @@ func (b *Backend) rxer(conn, rConn net.Conn) {
}
} else {
logrus.Errorf("error writing '%v': %v", rConn.RemoteAddr(), err)
_ = rConn.Close()
_ = conn.Close()
return
}
} else {
logrus.Errorf("read error '%v': %v", rConn.RemoteAddr(), err)
_ = rConn.Close()
_ = conn.Close()
return
}
}
}
func (b *Backend) txer(conn, rConn net.Conn) {
logrus.Infof("started '%v' <=> '%v'", conn.RemoteAddr(), rConn.RemoteAddr())
defer logrus.Warnf("exited '%v' <=> '%v'", conn.RemoteAddr(), rConn.RemoteAddr())
buf := make([]byte, 10240)
for {
if rxsz, err := rConn.Read(buf); err == nil {
@ -96,10 +106,14 @@ func (b *Backend) txer(conn, rConn net.Conn) {
}
} else {
logrus.Errorf("error writing '%v': %v", conn.RemoteAddr(), err)
_ = rConn.Close()
_ = conn.Close()
return
}
} else {
logrus.Errorf("read error '%v': %v", conn.RemoteAddr(), err)
_ = rConn.Close()
_ = conn.Close()
return
}
}

View File

@ -74,6 +74,9 @@ func (f *Frontend) accept(conn transport.Conn) {
}
func (f *Frontend) rxer(conn transport.Conn, zConn edge.Conn) {
logrus.Infof("started '%v' <=> '%v'", conn.RemoteAddr(), zConn.RemoteAddr())
defer logrus.Warnf("exited '%v' <=> '%v'", conn.RemoteAddr(), zConn.RemoteAddr())
buf := make([]byte, 10240)
for {
if rxsz, err := conn.Read(buf); err == nil {
@ -83,16 +86,23 @@ func (f *Frontend) rxer(conn transport.Conn, zConn edge.Conn) {
}
} else {
logrus.Errorf("error writing '%v': %v", zConn.RemoteAddr(), err)
_ = zConn.Close()
_ = conn.Close()
return
}
} else {
logrus.Errorf("read error '%v': %v", zConn.RemoteAddr(), err)
_ = zConn.Close()
_ = conn.Close()
return
}
}
}
func (f *Frontend) txer(conn transport.Conn, zConn edge.Conn) {
logrus.Infof("started '%v' <=> '%v'", conn.RemoteAddr(), zConn.RemoteAddr())
defer logrus.Warnf("exited '%v' <=> '%v'", conn.RemoteAddr(), zConn.RemoteAddr())
buf := make([]byte, 10240)
for {
if rxsz, err := zConn.Read(buf); err == nil {
@ -102,10 +112,14 @@ func (f *Frontend) txer(conn transport.Conn, zConn edge.Conn) {
}
} else {
logrus.Errorf("error writing '%v': %v", conn.RemoteAddr(), err)
_ = zConn.Close()
_ = conn.Close()
return
}
} else {
logrus.Errorf("read error '%v': %v", conn.RemoteAddr(), err)
_ = zConn.Close()
_ = conn.Close()
return
}
}