All matching opened files will now be closed during logoff

This commit is contained in:
Tal Aloni 2017-03-04 14:12:02 +02:00
parent cff82dd4b8
commit 9141665ac6
4 changed files with 38 additions and 2 deletions

View file

@ -79,8 +79,14 @@ namespace SMBLibrary.Server
public void RemoveSession(ushort userID) public void RemoveSession(ushort userID)
{ {
SMB1Session session;
m_sessions.TryGetValue(userID, out session);
if (session != null)
{
session.Close();
m_sessions.Remove(userID); m_sessions.Remove(userID);
} }
}
/// <summary> /// <summary>
/// An open TID MUST be unique within an SMB connection. /// An open TID MUST be unique within an SMB connection.

View file

@ -152,6 +152,18 @@ namespace SMBLibrary.Server
m_openSearches.Remove(searchHandle); m_openSearches.Remove(searchHandle);
} }
/// <summary>
/// Free all resources used by this session
/// </summary>
public void Close()
{
List<ushort> treeIDList = new List<ushort>(m_connectedTrees.Keys);
foreach (ushort treeID in treeIDList)
{
DisconnectTree(treeID);
}
}
public ushort UserID public ushort UserID
{ {
get get

View file

@ -60,8 +60,14 @@ namespace SMBLibrary.Server
public void RemoveSession(ulong sessionID) public void RemoveSession(ulong sessionID)
{ {
SMB2Session session;
m_sessions.TryGetValue(sessionID, out session);
if (session != null)
{
session.Close();
m_sessions.Remove(sessionID); m_sessions.Remove(sessionID);
} }
}
public void ClearSessions() public void ClearSessions()
{ {

View file

@ -152,6 +152,18 @@ namespace SMBLibrary.Server
m_openSearches.Remove(fileID); m_openSearches.Remove(fileID);
} }
/// <summary>
/// Free all resources used by this session
/// </summary>
public void Close()
{
List<uint> treeIDList = new List<uint>(m_connectedTrees.Keys);
foreach (uint treeID in treeIDList)
{
DisconnectTree(treeID);
}
}
public byte[] SessionKey public byte[] SessionKey
{ {
get get