private void DropConnection()
{
if (this.Connection != null)
{
if (this.Connection.CloseReason == null)
{
this.logger.Trace(m => m("{0}: closing connection.", this.Endpoint));
try
{
this.Connection.Close(500);
if (this.Connection.CloseReason != null)
{
this.Connection.Abort(500);
}
}
catch (AlreadyClosedException ex)
{
this.logger.WarnFormat("{0}: connection is already closed. Possible race condition.", ex, this.Endpoint);
}
this.logger.Trace(m => m("{0}: disposing connection.", this.Endpoint));
}
this.Connection = null;
}
}