mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-25 06:05:46 +03:00
Fix IpList queries not cancelling when disposed
This commit is contained in:
parent
f8960c8971
commit
93223cb30a
@ -135,7 +135,7 @@ void ReleaseQuery()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public virtual void Dispose()
|
||||||
{
|
{
|
||||||
ReleaseQuery();
|
ReleaseQuery();
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
using Steamworks.Data;
|
using System.Collections.Generic;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Steamworks.ServerList
|
namespace Steamworks.ServerList
|
||||||
@ -30,15 +26,17 @@ public override async Task<bool> RunQueryAsync( float timeoutSeconds = 10 )
|
|||||||
|
|
||||||
var ips = Ips.ToArray();
|
var ips = Ips.ToArray();
|
||||||
|
|
||||||
while ( true )
|
wantsCancel = false;
|
||||||
|
|
||||||
|
while ( !wantsCancel )
|
||||||
{
|
{
|
||||||
var sublist = ips.Skip( pointer ).Take( blockSize );
|
var sublist = ips.Skip( pointer ).Take( blockSize ).ToList();
|
||||||
if ( sublist.Count() == 0 )
|
if ( sublist.Count == 0 )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
using ( var list = new ServerList.Internet() )
|
using ( var list = new ServerList.Internet() )
|
||||||
{
|
{
|
||||||
list.AddFilter( "or", sublist.Count().ToString() );
|
list.AddFilter( "or", sublist.Count.ToString() );
|
||||||
|
|
||||||
foreach ( var server in sublist )
|
foreach ( var server in sublist )
|
||||||
{
|
{
|
||||||
@ -47,9 +45,6 @@ public override async Task<bool> RunQueryAsync( float timeoutSeconds = 10 )
|
|||||||
|
|
||||||
await list.RunQueryAsync( timeoutSeconds );
|
await list.RunQueryAsync( timeoutSeconds );
|
||||||
|
|
||||||
if ( wantsCancel )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
Responsive.AddRange( list.Responsive );
|
Responsive.AddRange( list.Responsive );
|
||||||
Responsive = Responsive.Distinct().ToList();
|
Responsive = Responsive.Distinct().ToList();
|
||||||
Unresponsive.AddRange( list.Unresponsive );
|
Unresponsive.AddRange( list.Unresponsive );
|
||||||
@ -64,9 +59,17 @@ public override async Task<bool> RunQueryAsync( float timeoutSeconds = 10 )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// note: Cancel doesn't get called in Dispose because request is always null for this class
|
||||||
public override void Cancel()
|
public override void Cancel()
|
||||||
{
|
{
|
||||||
wantsCancel = true;
|
wantsCancel = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Dispose()
|
||||||
|
{
|
||||||
|
base.Dispose();
|
||||||
|
|
||||||
|
wantsCancel = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user