-
-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for ObjectDisposedException
in PodeRequest.Receive
During SSL/TLS Operations
#1460
base: develop
Are you sure you want to change the base?
Conversation
return false; | ||
} | ||
|
||
await StreamLock.WaitAsync(cancellationToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Semaphore's aren't needed, because of the way the Receiving works this method will only ever been called one-at-a-time for one Request object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes you are right. I added it when I was trying to fix the reported issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to reinstate it because otherwise everything fails
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this, I was more referring that the StreamLock
variable entirely can go - because of how code will drop into this method, Semaphores shouldn't be required, and the locking will just add overhead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot remove the Semaphores. there are multiple receive calls I presume.
Pull Request: Fix for
ObjectDisposedException
inPodeRequest.Receive
During SSL/TLS OperationsSummary
This pull request addresses #1459
Intermittent
ObjectDisposedException
that occurs in thePodeRequest.Receive
method during SSL/TLS operations in Pode. The issue arises due to premature disposal or concurrent access of theSslStream
instance when handling HTTPS requests under high concurrency.Problem
The following error was observed when running a Pode server with an HTTPS endpoint under load:
The issue is caused by:
SslStream
instance is disposed of while operations are still in progress.SslStream
without proper synchronization.Changes Made
Improved Thread Safety:
SslStream
are thread-safe, usingSemaphoreSlim
to manage concurrency.Enhanced Disposal Logic:
Dispose
method inPodeRequest
to ensure that theSslStream
is not disposed prematurely.IsDisposed
andIsOpen
state checks to prevent operations on already-disposed streams.Error Logging:
ObjectDisposedException
andIOException
) to avoid alarming users unnecessarily. These exceptions are now logged at theVerbose
level instead ofError
.Buffer Management:
Stream Cleanup:
InputStream
.Results
ObjectDisposedException
no longer occurs under high-concurrency scenarios.Impact
Backward Compatibility