mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 23:00:55 +03:00
remove check for cache key collisions
we use sha256 keys now Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -1167,11 +1167,10 @@ func (c *sftpConnectionsCache) Get(config *SFTPFsConfig, sessionID string) (*sft
|
|||||||
c.Lock()
|
c.Lock()
|
||||||
defer c.Unlock()
|
defer c.Unlock()
|
||||||
|
|
||||||
var oldKey string
|
|
||||||
for {
|
for {
|
||||||
if val, ok := c.items[key]; ok {
|
if val, ok := c.items[key]; ok {
|
||||||
activeSessions := val.ActiveSessions()
|
activeSessions := val.ActiveSessions()
|
||||||
if activeSessions < maxSessionsPerConnection || key == oldKey {
|
if activeSessions < maxSessionsPerConnection {
|
||||||
logger.Debug(logSenderSFTPCache, "",
|
logger.Debug(logSenderSFTPCache, "",
|
||||||
"reusing connection for session ID %q, key %s, active sessions %d, active connections: %d",
|
"reusing connection for session ID %q, key %s, active sessions %d, active connections: %d",
|
||||||
sessionID, key, activeSessions+1, len(c.items))
|
sessionID, key, activeSessions+1, len(c.items))
|
||||||
@@ -1179,11 +1178,10 @@ func (c *sftpConnectionsCache) Get(config *SFTPFsConfig, sessionID string) (*sft
|
|||||||
return val, nil
|
return val, nil
|
||||||
}
|
}
|
||||||
partition++
|
partition++
|
||||||
oldKey = key
|
|
||||||
key = config.getUniqueID(partition)
|
key = config.getUniqueID(partition)
|
||||||
logger.Debug(logSenderSFTPCache, "",
|
logger.Debug(logSenderSFTPCache, "",
|
||||||
"connection full, generated new key for partition: %d, active sessions: %d, key: %s, old key: %s",
|
"connection full, generated new key for partition: %d, active sessions: %d, key: %s",
|
||||||
partition, activeSessions, oldKey, key)
|
partition, activeSessions, key)
|
||||||
} else {
|
} else {
|
||||||
conn := newSFTPConnection(config, sessionID)
|
conn := newSFTPConnection(config, sessionID)
|
||||||
signer, err := config.getKeySigner()
|
signer, err := config.getKeySigner()
|
||||||
|
|||||||
Reference in New Issue
Block a user