Explicit session.Close() call is indeed needed

This commit is contained in:
Andy Wang 2020-12-18 23:29:17 +00:00
parent be53fa37a0
commit 6b6b1b349f
No known key found for this signature in database
GPG Key ID: 181B49F9F38F3374
1 changed files with 6 additions and 0 deletions

View File

@ -39,6 +39,9 @@ func RouteUDP(bindFunc func() (*net.UDPConn, error), streamTimeout time.Duration
stream, err = sesh.OpenStream()
if err != nil {
if singleplex {
sesh.Close()
}
log.Errorf("Failed to open stream: %v", err)
continue
}
@ -106,6 +109,9 @@ func RouteTCP(listener net.Listener, streamTimeout time.Duration, singleplex boo
if err != nil {
log.Errorf("Failed to open stream: %v", err)
localConn.Close()
if singleplex {
sesh.Close()
}
return
}