Skip to content
Merged
Show file tree
Hide file tree
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 @@ -147,10 +147,10 @@ internal bool IsNonBlocking
internal bool IsUnderlyingHandleBlocking => !AsyncContext.IsHandleNonBlocking;

/// <summary>
/// Sets the underlying socket to blocking mode.
/// Attempts to set the underlying socket to blocking mode.
/// Only sets blocking if the user hasn't explicitly set Blocking = false (i.e., IsNonBlocking is false).
/// This is only safe to call when the socket is guaranteed by construction to not be used concurrently
/// with any other operation, such as at the completion of ConnectAsync.
/// with any other I/O operation, such as at the completion of ConnectAsync. Concurrent disposal is allowed.
/// </summary>
internal void SetBlocking()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,9 +609,16 @@ public void SetHandleBlocking()

if (_isHandleNonBlocking)
{
if (Interop.Sys.Fcntl.SetIsNonBlocking(_socket, 0) == 0)
try
{
_isHandleNonBlocking = false;
if (Interop.Sys.Fcntl.SetIsNonBlocking(_socket, 0) == 0)
{
_isHandleNonBlocking = false;
}
}
catch (ObjectDisposedException)
{
// Concurrent disposal is allowed; restoring blocking mode is only an optimization.
}
}
}
Expand Down
Loading