connection: add a close method
and use it instead of netConn directly
This commit is contained in:
parent
784f75f45b
commit
9794ca7ee0
2 changed files with 8 additions and 7 deletions
|
@ -579,6 +579,10 @@ func (c Connection) createMissingDirs(filePath string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c Connection) close() error {
|
||||
return c.netConn.Close()
|
||||
}
|
||||
|
||||
func getOSOpenFlags(requestFlags sftp.FileOpenFlags) (flags int) {
|
||||
var osFlags int
|
||||
if requestFlags.Read && requestFlags.Write {
|
||||
|
|
|
@ -173,8 +173,8 @@ func CloseActiveConnection(connectionID string) bool {
|
|||
defer mutex.RUnlock()
|
||||
for _, c := range openConnections {
|
||||
if c.ID == connectionID {
|
||||
err := c.netConn.Close()
|
||||
c.Log(logger.LevelDebug, logSender, "close connection requested, err: %v", err)
|
||||
err := c.close()
|
||||
c.Log(logger.LevelDebug, logSender, "close connection requested, close err: %v", err)
|
||||
result = true
|
||||
break
|
||||
}
|
||||
|
@ -254,11 +254,8 @@ func CheckIdleConnections() {
|
|||
}
|
||||
}
|
||||
if idleTime > idleTimeout {
|
||||
c.Log(logger.LevelInfo, logSender, "close idle connection, idle time: %v", idleTime)
|
||||
err := c.netConn.Close()
|
||||
if err != nil {
|
||||
c.Log(logger.LevelWarn, logSender, "idle connection close failed: %v", err)
|
||||
}
|
||||
err := c.close()
|
||||
c.Log(logger.LevelInfo, logSender, "close idle connection, idle time: %v, close error: %v", idleTime, err)
|
||||
}
|
||||
}
|
||||
logger.Debug(logSender, "", "check idle connections ended")
|
||||
|
|
Loading…
Reference in a new issue