Skip to content

Commit 172ec24

Browse files
Update StackLock condition to enter in HTTPProcessor.
Update StackLock condition to enter in HTTPProcessor. This check is best if we have plenty of large file downloads.
1 parent 2298d8a commit 172ec24

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

BackendServices/CyberBackendLibrary/HTTP/HTTPProcessor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -889,10 +889,10 @@ private static void CopyStream(Stream input, Stream output, int BufferSize)
889889

890890
try
891891
{
892-
// Attempt to acquire the lock
893-
Monitor.TryEnter(_StackLock, ref lockTaken);
892+
if (BufferSize <= 4096) // Make sure buffersize is not outside of tolerated stack space.
893+
Monitor.TryEnter(_StackLock, ref lockTaken); // Attempt to acquire the lock
894894

895-
if (lockTaken && BufferSize <= 4096) // Lock is free and buffersize is not outside of tolerated stack space.
895+
if (lockTaken) // Lock is free.
896896
{
897897
Span<byte> buffer = stackalloc byte[BufferSize]; // Allocate buffer on the stack.
898898
buffer.Clear(); // Explicit zero initialize, because stack can contains garbage data.

0 commit comments

Comments
 (0)