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

Fixing WCF 1888 by eliminating timing issue #2704

Merged
merged 1 commit into from
Mar 30, 2018
Merged
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 @@ -511,26 +511,26 @@ private void ThrowIfClosed()
private Exception ConvertSendException(SocketException socketException, TimeSpan remainingTime)
{
return ConvertTransferException(socketException, _sendTimeout, socketException,
TransferOperation.Write, _aborted, _timeoutErrorString, _timeoutErrorTransferOperation, this, remainingTime);
_aborted, _timeoutErrorString, _timeoutErrorTransferOperation, this, remainingTime);
}

private Exception ConvertReceiveException(SocketException socketException, TimeSpan remainingTime)
{
return ConvertTransferException(socketException, _receiveTimeout, socketException,
TransferOperation.Read, _aborted, _timeoutErrorString, _timeoutErrorTransferOperation, this, remainingTime);
_aborted, _timeoutErrorString, _timeoutErrorTransferOperation, this, remainingTime);
}

internal static Exception ConvertTransferException(SocketException socketException, TimeSpan timeout, Exception originalException)
{
return ConvertTransferException(socketException, timeout, originalException,
TransferOperation.Undefined, false, null, TransferOperation.Undefined, null, TimeSpan.MaxValue);
false, null, TransferOperation.Undefined, null, TimeSpan.MaxValue);
}

private Exception ConvertObjectDisposedException(ObjectDisposedException originalException, TransferOperation transferOperation)
{
if (_timeoutErrorString != null)
{
return ConvertTimeoutErrorException(originalException, transferOperation, _timeoutErrorString, _timeoutErrorTransferOperation);
return ConvertTimeoutErrorException(originalException, _timeoutErrorString, _timeoutErrorTransferOperation);
}
else if (_aborted)
{
Expand All @@ -543,7 +543,7 @@ private Exception ConvertObjectDisposedException(ObjectDisposedException origina
}

private static Exception ConvertTransferException(SocketException socketException, TimeSpan timeout, Exception originalException,
TransferOperation transferOperation, bool aborted, string timeoutErrorString, TransferOperation timeoutErrorTransferOperation,
bool aborted, string timeoutErrorString, TransferOperation timeoutErrorTransferOperation,
SocketConnection socketConnection, TimeSpan remainingTime)
{
if ((int)socketException.SocketErrorCode == UnsafeNativeMethods.ERROR_INVALID_HANDLE)
Expand All @@ -553,7 +553,7 @@ private static Exception ConvertTransferException(SocketException socketExceptio

if (timeoutErrorString != null)
{
return ConvertTimeoutErrorException(originalException, transferOperation, timeoutErrorString, timeoutErrorTransferOperation);
return ConvertTimeoutErrorException(originalException, timeoutErrorString, timeoutErrorTransferOperation);
}

// 10053 can occur due to our timeout sockopt firing, so map to TimeoutException in that case
Expand Down Expand Up @@ -597,12 +597,11 @@ private static Exception ConvertTransferException(SocketException socketExceptio
}
}

private static Exception ConvertTimeoutErrorException(Exception originalException,
TransferOperation transferOperation, string timeoutErrorString, TransferOperation timeoutErrorTransferOperation)
private static Exception ConvertTimeoutErrorException(Exception originalException, string timeoutErrorString, TransferOperation timeoutErrorTransferOperation)
{
Contract.Assert(timeoutErrorString != null, "Argument timeoutErrorString must not be null.");

if (transferOperation == timeoutErrorTransferOperation)
if (timeoutErrorTransferOperation != TransferOperation.Undefined)
{
return new TimeoutException(timeoutErrorString, originalException);
}
Expand Down