All matching opened files will now be closed during connection termination

This commit is contained in:
Tal Aloni 2017-03-04 14:32:17 +02:00
parent 9141665ac6
commit 900ff25a3c
4 changed files with 24 additions and 1 deletions

View file

@ -40,6 +40,7 @@ namespace SMBLibrary.Server
{ {
connection.SendQueue.Stop(); connection.SendQueue.Stop();
SocketUtils.ReleaseSocket(connection.ClientSocket); SocketUtils.ReleaseSocket(connection.ClientSocket);
connection.CloseSessions();
RemoveConnection(connection); RemoveConnection(connection);
} }
} }

View file

@ -43,6 +43,13 @@ namespace SMBLibrary.Server
Dialect = state.Dialect; Dialect = state.Dialect;
} }
/// <summary>
/// Free all resources used by the active sessions in this connection
/// </summary>
public virtual void CloseSessions()
{
}
public void LogToServer(Severity severity, string message) public void LogToServer(Severity severity, string message)
{ {
message = String.Format("[{0}] {1}", ConnectionIdentifier, message); message = String.Format("[{0}] {1}", ConnectionIdentifier, message);

View file

@ -88,6 +88,16 @@ namespace SMBLibrary.Server
} }
} }
public override void CloseSessions()
{
foreach (SMB1Session session in m_sessions.Values)
{
session.Close();
}
m_sessions.Clear();
}
/// <summary> /// <summary>
/// An open TID MUST be unique within an SMB connection. /// An open TID MUST be unique within an SMB connection.
/// The value 0xFFFF MUST NOT be used as a valid TID. All other possible values for TID, including zero (0x0000), are valid. /// The value 0xFFFF MUST NOT be used as a valid TID. All other possible values for TID, including zero (0x0000), are valid.

View file

@ -69,8 +69,13 @@ namespace SMBLibrary.Server
} }
} }
public void ClearSessions() public override void CloseSessions()
{ {
foreach (SMB2Session session in m_sessions.Values)
{
session.Close();
}
m_sessions.Clear(); m_sessions.Clear();
} }
} }