-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
CSHARP-3840: Unresponsive/deadlocked cluster.Dispose() #1557
Conversation
68fa96d
to
c240e1c
Compare
throw new TimeoutException(message); | ||
} | ||
if (state == 4) { throw new OperationCanceledException(); } | ||
WaitHandle.WaitAny(new[] { connectOperation.AsyncWaitHandle, cancellationToken.WaitHandle }, _settings.ConnectTimeout); |
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.
nit: [connectOperation.AsyncWaitHandle, cancellationToken.WaitHandle]
if (endPoint is DnsEndPoint dnsEndPoint) | ||
{ | ||
// mono doesn't support DnsEndPoint in its BeginConnect method. | ||
connectTask = Task.Factory.FromAsync(socket.BeginConnect(dnsEndPoint.Host, dnsEndPoint.Port, null, null), socket.EndConnect); |
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.
Please check if ConnectAsync
can replace BeginConnect
(SocketTaskExtensions
)
|
||
if (!connectOperation.IsCompleted) | ||
{ | ||
socket.Dispose(); |
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 think we need to hide Dispose
exceptions here, and probably in all cases?
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.
Done
{ | ||
// a timeout or operation cancelled exception will be thrown instead | ||
} | ||
socket.Dispose(); |
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.
Ignore exceptions?
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.
Done
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.
LGTM!
No description provided.