Skip to content
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

SmtpConnection: fix Socket not getting Disposed when LingerState cannot be set. #428

Merged
merged 1 commit into from
Jan 21, 2020
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
15 changes: 9 additions & 6 deletions src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1080,13 +1080,16 @@ private void GetConnection()

private void Abort()
{
try
{
// Try-catch commented out to identify exception that is causing
// https://github.com/dotnet/corefx/issues/40711.

// try
// {
_transport.Abort();
}
catch
{
}
// }
// catch
// {
// }
}

public void Dispose()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ internal partial class SmtpConnection
private readonly ChannelBinding _channelBindingToken = null;
private bool _enableSsl;
private X509CertificateCollection _clientCertificates;
#pragma warning disable CS0414
private bool _aborted; // Tracks whether Abort was called, for debugging https://github.com/dotnet/corefx/issues/40711.
#pragma warning restore CS0414

internal SmtpConnection(SmtpTransport parent, SmtpClient client, ICredentialsByHost credentials, ISmtpAuthenticationModule[] authenticationModules)
{
Expand Down Expand Up @@ -154,8 +151,6 @@ internal void ReleaseConnection()

internal void Abort()
{
_aborted = true;

if (!_isClosed)
{
lock (this)
Expand Down