Skip to content

Commit e14003d

Browse files
authored
refactor: improve resource management in singleTCPLoop by closing target connection
1 parent 398eff6 commit e14003d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

internal/common.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -877,11 +877,13 @@ func (c *Common) singleTCPLoop() error {
877877
return
878878
}
879879

880-
c.logger.Debug("Target connection: get relay-id <- pool active %v", c.tunnelPool.Active())
880+
c.logger.Debug("Target connection: get ******** <- pool active %v / %v per %v",
881+
c.tunnelPool.Active(), c.tunnelPool.Capacity(), c.tunnelPool.Interval())
881882

882883
defer func() {
883-
c.tunnelPool.Put("", targetConn)
884-
c.logger.Debug("Tunnel connection: put relay-id -> pool active %v", c.tunnelPool.Active())
884+
if targetConn != nil {
885+
targetConn.Close()
886+
}
885887
}()
886888

887889
c.targetTCPConn = targetConn.(*net.TCPConn)

0 commit comments

Comments
 (0)