mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-07-12 20:38:09 +02:00
NBTConnectionReceiveBuffer: Dispose: Fix thread-safety issue
This commit is contained in:
parent
39388660d3
commit
f366c78fc9
1 changed files with 14 additions and 6 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 2014-2023 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,
|
||||||
|
@ -15,6 +15,9 @@ namespace SMBLibrary.NetBios
|
||||||
{
|
{
|
||||||
public class NBTConnectionReceiveBuffer : IDisposable
|
public class NBTConnectionReceiveBuffer : IDisposable
|
||||||
{
|
{
|
||||||
|
#if NETSTANDARD2_0
|
||||||
|
private object m_bufferSyncLock = new object();
|
||||||
|
#endif
|
||||||
private byte[] m_buffer;
|
private byte[] m_buffer;
|
||||||
private int m_readOffset = 0;
|
private int m_readOffset = 0;
|
||||||
private int m_bytesInBuffer = 0;
|
private int m_bytesInBuffer = 0;
|
||||||
|
@ -127,14 +130,19 @@ namespace SMBLibrary.NetBios
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
#if NETSTANDARD2_0
|
||||||
|
lock (m_bufferSyncLock)
|
||||||
|
{
|
||||||
if (m_buffer != null)
|
if (m_buffer != null)
|
||||||
{
|
{
|
||||||
#if NETSTANDARD2_0
|
|
||||||
ArrayPool<byte>.Shared.Return(m_buffer);
|
ArrayPool<byte>.Shared.Return(m_buffer);
|
||||||
#endif
|
|
||||||
m_buffer = null;
|
m_buffer = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
m_buffer = null;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
public byte[] Buffer
|
public byte[] Buffer
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue