Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ internal sealed class SafeDeleteSslContext : SafeDeleteContext
// mapped from OSX error codes
private const int InitialBufferSize = 2048;
private readonly SafeSslHandle _sslContext;
private readonly object _lock = new object();
private ArrayBuffer _inputBuffer = new ArrayBuffer(InitialBufferSize);
private ArrayBuffer _outputBuffer = new ArrayBuffer(InitialBufferSize);

Expand Down Expand Up @@ -202,7 +203,7 @@ protected override void Dispose(bool disposing)
SafeSslHandle sslContext = _sslContext;
if (null != sslContext)
{
lock (_sslContext)
lock (_lock)
{
_inputBuffer.Dispose();
_outputBuffer.Dispose();
Expand All @@ -225,7 +226,7 @@ private static unsafe int WriteToConnection(IntPtr connection, byte* data, void*
// but if we were to pool the buffers we would have a potential use-after-free issue.
try
{
lock (context)
lock (context._lock)
{
ulong length = (ulong)*dataLength;
Debug.Assert(length <= int.MaxValue);
Expand Down Expand Up @@ -257,7 +258,7 @@ private static unsafe int ReadFromConnection(IntPtr connection, byte* data, void

try
{
lock (context)
lock (context._lock)
{
ulong toRead = (ulong)*dataLength;

Expand Down Expand Up @@ -294,7 +295,7 @@ private static unsafe int ReadFromConnection(IntPtr connection, byte* data, void

internal void Write(ReadOnlySpan<byte> buf)
{
lock (_sslContext)
lock (_lock)
{
_inputBuffer.EnsureAvailableSpace(buf.Length);
buf.CopyTo(_inputBuffer.AvailableSpan);
Expand All @@ -306,7 +307,7 @@ internal void Write(ReadOnlySpan<byte> buf)

internal void ReadPendingWrites(ref ProtocolToken token)
{
lock (_sslContext)
lock (_lock)
{
if (_outputBuffer.ActiveLength == 0)
{
Expand All @@ -328,7 +329,7 @@ internal int ReadPendingWrites(byte[] buf, int offset, int count)
Debug.Assert(count >= 0);
Debug.Assert(count <= buf.Length - offset);

lock (_sslContext)
lock (_lock)
{
int limit = Math.Min(count, _outputBuffer.ActiveLength);

Expand Down
Loading