Commit 42e44b92 authored by Marc Gravell's avatar Marc Gravell

Don't try and CancelConnect if the connect succeeded

parent 91f699a0
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Pipelines.Sockets.Unofficial" Version="0.2.1-alpha.62" /> <PackageReference Include="Pipelines.Sockets.Unofficial" Version="0.2.1-alpha.63" />
<PackageReference Include="System.Threading.Channels" Version="4.5.0" /> <PackageReference Include="System.Threading.Channels" Version="4.5.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>
\ No newline at end of file
...@@ -180,9 +180,15 @@ private static void ConfigureTimeout(SocketAsyncEventArgs args, int timeoutMilli ...@@ -180,9 +180,15 @@ private static void ConfigureTimeout(SocketAsyncEventArgs args, int timeoutMilli
var timeout = Task.Delay(timeoutMilliseconds); var timeout = Task.Delay(timeoutMilliseconds);
timeout.ContinueWith((_, state) => timeout.ContinueWith((_, state) =>
{ {
var a = (SocketAsyncEventArgs)state; try
try { Socket.CancelConnectAsync(a); } catch { } {
try { ((SocketAwaitable)a.UserToken).Complete(0, SocketError.TimedOut); } catch { } var a = (SocketAsyncEventArgs)state;
if (((SocketAwaitable)a.UserToken).TryComplete(0, SocketError.TimedOut))
{
Socket.CancelConnectAsync(a);
}
}
catch { }
}, args); }, args);
} }
......
...@@ -14,8 +14,4 @@ ...@@ -14,8 +14,4 @@
<ProjectReference Include="..\BasicTest\BasicTest.csproj" /> <ProjectReference Include="..\BasicTest\BasicTest.csproj" />
<ProjectReference Include="..\StackExchange.Redis\StackExchange.Redis.csproj" /> <ProjectReference Include="..\StackExchange.Redis\StackExchange.Redis.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<PackageReference Include="Pipelines.Sockets.Unofficial" Version="0.2.1-alpha.62" />
</ItemGroup>
</Project> </Project>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment