Socket available bytes check: add a disposal guard#1836
Merged
NickCraver merged 1 commit intomainfrom Aug 18, 2021
Merged
Conversation
This prevents a disposal race from killing us in connection phases and such, protected against in the counters above in Unofficial (see https://github.com/mgravell/Pipelines.Sockets.Unofficial/blob/19b141f30fe2485dd79993be0ac87a9fc6b34b74/src/Pipelines.Sockets.Unofficial/SocketConnection.cs#L235) but not here - adding the same protection guard. Stack trace of such an error: ``` ----- Inner Stack Trace ----- at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success) at System.StubHelpers.StubHelpers.SafeHandleAddRef(SafeHandle pHandle, Boolean& success) at Interop.Winsock.ioctlsocket(SafeSocketHandle socketHandle, Int32 cmd, Int32& argp) at System.Net.Sockets.SocketPal.GetAvailable(SafeSocketHandle handle, Int32& available) at System.Net.Sockets.Socket.get_Available() at StackExchange.Redis.PhysicalConnection.GetSocketBytes(Int64& readCount, Int64& writeCount) in /_/src/StackExchange.Redis/PhysicalConnection.cs:line 1250 at StackExchange.Redis.PhysicalBridge.GetOutstandingCount(Int32& inst, Int32& qs, Int64& in, Int32& qu, Boolean& aw, Int64& toRead, Int64& toWrite, BacklogStatus& bs, ReadStatus& rs, WriteStatus& ws) in /_/src/StackExchange.Redis/PhysicalBridge.cs:line 304 at StackExchange.Redis.ConnectionMultiplexer.ReconfigureAsync(Boolean first, Boolean reconfigureAll, LogProxy log, EndPoint blame, String cause, Boolean publishReconfigure, CommandFlags publishReconfigureFlags) in /_/src/StackExchange.Redis/ConnectionMultiplexer.cs:line 1748 ```
mgravell
approved these changes
Aug 18, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This prevents a disposal race from killing us in connection phases and such, protected against in the counters above in Unofficial (see https://github.com/mgravell/Pipelines.Sockets.Unofficial/blob/19b141f30fe2485dd79993be0ac87a9fc6b34b74/src/Pipelines.Sockets.Unofficial/SocketConnection.cs#L235) but not here - adding the same protection guard.
Stack trace of such an error: