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
|
* 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,
|
* the GNU Lesser Public License as published by the Free Software Foundation,
|
||||||
|
@ -78,14 +78,20 @@ namespace SMBLibrary.Server
|
||||||
public SMB1Session GetSession(ushort userID)
|
public SMB1Session GetSession(ushort userID)
|
||||||
{
|
{
|
||||||
SMB1Session session;
|
SMB1Session session;
|
||||||
|
lock (m_sessions)
|
||||||
|
{
|
||||||
m_sessions.TryGetValue(userID, out session);
|
m_sessions.TryGetValue(userID, out session);
|
||||||
|
}
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveSession(ushort userID)
|
public void RemoveSession(ushort userID)
|
||||||
{
|
{
|
||||||
SMB1Session session;
|
SMB1Session session;
|
||||||
|
lock (m_sessions)
|
||||||
|
{
|
||||||
m_sessions.TryGetValue(userID, out session);
|
m_sessions.TryGetValue(userID, out session);
|
||||||
|
}
|
||||||
if (session != null)
|
if (session != null)
|
||||||
{
|
{
|
||||||
session.Close();
|
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
|
* 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,
|
* the GNU Lesser Public License as published by the Free Software Foundation,
|
||||||
|
@ -56,14 +56,20 @@ namespace SMBLibrary.Server
|
||||||
public SMB2Session GetSession(ulong sessionID)
|
public SMB2Session GetSession(ulong sessionID)
|
||||||
{
|
{
|
||||||
SMB2Session session;
|
SMB2Session session;
|
||||||
|
lock (m_sessions)
|
||||||
|
{
|
||||||
m_sessions.TryGetValue(sessionID, out session);
|
m_sessions.TryGetValue(sessionID, out session);
|
||||||
|
}
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveSession(ulong sessionID)
|
public void RemoveSession(ulong sessionID)
|
||||||
{
|
{
|
||||||
SMB2Session session;
|
SMB2Session session;
|
||||||
|
lock (m_sessions)
|
||||||
|
{
|
||||||
m_sessions.TryGetValue(sessionID, out session);
|
m_sessions.TryGetValue(sessionID, out session);
|
||||||
|
}
|
||||||
if (session != null)
|
if (session != null)
|
||||||
{
|
{
|
||||||
session.Close();
|
session.Close();
|
||||||
|
|
Loading…
Add table
Reference in a new issue