1
0
mirror of https://github.com/drakkan/sftpgo.git synced 2025-11-29 22:08:10 +02:00

connections: close the ssh channel before the network connection

This way if pkg/sftp is stuck in Serve() method should be unlocked.
This commit is contained in:
Nicola Murino
2019-09-11 16:29:56 +02:00
parent 9794ca7ee0
commit 3d13fe15c3
4 changed files with 70 additions and 56 deletions

View File

@@ -13,6 +13,7 @@ import (
"github.com/drakkan/sftpgo/utils"
"github.com/rs/xid"
"golang.org/x/crypto/ssh"
"github.com/drakkan/sftpgo/dataprovider"
"github.com/drakkan/sftpgo/logger"
@@ -37,6 +38,7 @@ type Connection struct {
protocol string
lock *sync.Mutex
netConn net.Conn
channel ssh.Channel
}
// Log outputs a log entry to the configured logger
@@ -580,6 +582,10 @@ func (c Connection) createMissingDirs(filePath string) error {
}
func (c Connection) close() error {
if c.channel != nil {
err := c.channel.Close()
c.Log(logger.LevelInfo, logSender, "channel close, err: %v", err)
}
return c.netConn.Close()
}