Skip to content
This repository has been archived by the owner on Jun 8, 2024. It is now read-only.

Commit

Permalink
fix bug #12 and remove timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
lontivero committed Aug 9, 2014
1 parent 3d0c611 commit f3c6beb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
8 changes: 5 additions & 3 deletions Open.Nat/Upnp/UpnpNatDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@ await _soapClient
mapping.PublicIP = IPAddress.None;
CreatePortMapAsync(mapping);
break;
//case UpnpConstants.ExternalPortOnlySupportsWildcard:
// NatUtility.TraceSource.LogWarn("External Port Only Supports Wildcard");
// break;
case UpnpConstants.ExternalPortOnlySupportsWildcard:
NatDiscoverer.TraceSource.LogWarn("External Port Only Supports Wildcard");
throw;
default:
throw;
}
}
}
Expand Down
20 changes: 9 additions & 11 deletions Open.Nat/Utils/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,17 @@ internal static string ToPrintableXml(this XmlDocument document)

public static async Task<TResult> TimeoutAfter<TResult>(this Task<TResult> task, TimeSpan timeout)
{
#if DEBUG
return await task;
#endif
var timeoutCancellationTokenSource = new CancellationTokenSource();
//var timeoutCancellationTokenSource = new CancellationTokenSource();

Task completedTask = await Task.WhenAny(task, Task.Delay(timeout, timeoutCancellationTokenSource.Token));
if (completedTask == task)
{
timeoutCancellationTokenSource.Cancel();
return await task;
}
throw new TimeoutException(
"The operation has timed out. The network is broken, router has gone or is too busy.");
//Task completedTask = await Task.WhenAny(task, Task.Delay(timeout, timeoutCancellationTokenSource.Token));
//if (completedTask == task)
//{
// timeoutCancellationTokenSource.Cancel();
// return await task;
//}
//throw new TimeoutException(
// "The operation has timed out. The network is broken, router has gone or is too busy.");
}
}
}

0 comments on commit f3c6beb

Please sign in to comment.