mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-04-30 10:47:48 +02:00
Server: ConnectionState: Fix thread-safety issue
This commit is contained in:
parent
cf182e787f
commit
1a8c94ba94
2 changed files with 18 additions and 6 deletions
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2014-2019 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
|
||||
/* Copyright (C) 2014-2024 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
|
||||
*
|
||||
* You can redistribute this program and/or modify it under the terms of
|
||||
* the GNU Lesser Public License as published by the Free Software Foundation,
|
||||
|
@ -78,14 +78,20 @@ namespace SMBLibrary.Server
|
|||
public SMB1Session GetSession(ushort userID)
|
||||
{
|
||||
SMB1Session session;
|
||||
m_sessions.TryGetValue(userID, out session);
|
||||
lock (m_sessions)
|
||||
{
|
||||
m_sessions.TryGetValue(userID, out session);
|
||||
}
|
||||
return session;
|
||||
}
|
||||
|
||||
public void RemoveSession(ushort userID)
|
||||
{
|
||||
SMB1Session session;
|
||||
m_sessions.TryGetValue(userID, out session);
|
||||
lock (m_sessions)
|
||||
{
|
||||
m_sessions.TryGetValue(userID, out session);
|
||||
}
|
||||
if (session != null)
|
||||
{
|
||||
session.Close();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2014-2020 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
|
||||
/* Copyright (C) 2014-2024 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
|
||||
*
|
||||
* You can redistribute this program and/or modify it under the terms of
|
||||
* the GNU Lesser Public License as published by the Free Software Foundation,
|
||||
|
@ -56,14 +56,20 @@ namespace SMBLibrary.Server
|
|||
public SMB2Session GetSession(ulong sessionID)
|
||||
{
|
||||
SMB2Session session;
|
||||
m_sessions.TryGetValue(sessionID, out session);
|
||||
lock (m_sessions)
|
||||
{
|
||||
m_sessions.TryGetValue(sessionID, out session);
|
||||
}
|
||||
return session;
|
||||
}
|
||||
|
||||
public void RemoveSession(ulong sessionID)
|
||||
{
|
||||
SMB2Session session;
|
||||
m_sessions.TryGetValue(sessionID, out session);
|
||||
lock (m_sessions)
|
||||
{
|
||||
m_sessions.TryGetValue(sessionID, out session);
|
||||
}
|
||||
if (session != null)
|
||||
{
|
||||
session.Close();
|
||||
|
|
Loading…
Add table
Reference in a new issue