Cancel work if CDNClientPool is exhausted and can't find more servers

This commit is contained in:
Ryan Kistner committed 2017-12-01 00:40:08 -07:00
1 parent 184ea54020
commit 65036ffa8d
2 files changed
+11

No files matched your search

+9
View File
@@ -24,6 +24,7 @@ namespace DepotDownloader
private AutoResetEvent populatePoolEvent;
private Task monitorTask;
public CancellationTokenSource ExhaustedToken { get; set; }
public CDNClientPool(Steam3Session steamSession)
{
@@ -61,6 +62,8 @@ namespace DepotDownloader
private async Task ConnectionPoolMonitorAsync()
{
bool didPopulate = false;
while(true)
{
populatePoolEvent.WaitOne(TimeSpan.FromSeconds(1));
@@ -86,6 +89,12 @@ namespace DepotDownloader
availableServerEndpoints.Add(endpoint.Item1);
}
}
didPopulate = true;
}
else if ( availableServerEndpoints.Count == 0 && !steamSession.steamClient.IsConnected && didPopulate )
{
ExhaustedToken?.Cancel();
}
}
}
+2
View File
@@ -545,6 +545,7 @@ namespace DepotDownloader
Console.WriteLine( "Downloading depot {0} - {1}", depot.id, depot.contentName );
CancellationTokenSource cts = new CancellationTokenSource();
cdnPool.ExhaustedToken = cts;
ProtoManifest oldProtoManifest = null;
ProtoManifest newProtoManifest = null;
@@ -874,6 +875,7 @@ namespace DepotDownloader
if ( chunkData == null )
{
Console.WriteLine( "Failed to find any server with chunk {0} for depot {1}. Aborting.", chunkID, depot.id );
cts.Cancel();
return;
}