mirror of
https://github.com/FabInfra/capnproto-dotnetcore_Runtime.git
synced 2025-03-12 23:01:44 +01:00
See comments on issue #3: Pending questions shall fail when connection is broken.
Adjusted required version of .NET Core runtime from 2.2 to 2.1
This commit is contained in:
parent
97eb340261
commit
eaecfda35e
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -10,7 +10,7 @@ using System.Threading.Tasks;
|
||||
namespace Capnp.Net.Runtime.Tests
|
||||
{
|
||||
[TestClass]
|
||||
public class TcpRpcAdvancedStuff: TestBase
|
||||
public class TcpRpcAdvancedStuff : TestBase
|
||||
{
|
||||
[TestMethod, Timeout(10000)]
|
||||
public void MultiConnect()
|
||||
@ -88,5 +88,37 @@ namespace Capnp.Net.Runtime.Tests
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(10000)]
|
||||
public void ClosingServerWhileRequestingBootstrap()
|
||||
{
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
var server = SetupServer();
|
||||
var counters = new Counters();
|
||||
var tcs = new TaskCompletionSource<int>();
|
||||
server.Main = new TestInterfaceImpl(counters, tcs);
|
||||
|
||||
using (var client = SetupClient())
|
||||
{
|
||||
Assert.IsTrue(client.WhenConnected.Wait(MediumNonDbgTimeout));
|
||||
|
||||
using (var main = client.GetMain<ITestInterface>())
|
||||
{
|
||||
server.Dispose();
|
||||
|
||||
// Resolution must either succeed or be cancelled. A hanging resolution would be inacceptable.
|
||||
|
||||
try
|
||||
{
|
||||
Assert.IsTrue(((IResolvingCapability)main).WhenResolved.Wait(MediumNonDbgTimeout));
|
||||
}
|
||||
catch (AggregateException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -751,7 +751,19 @@ namespace Capnp.Net.Runtime.Tests
|
||||
using (var main = client.GetMain<ITestMoreStuff>())
|
||||
{
|
||||
var resolving = main as IResolvingCapability;
|
||||
if (!resolving.WhenResolved.Wait(MediumNonDbgTimeout))
|
||||
|
||||
bool success;
|
||||
|
||||
try
|
||||
{
|
||||
success = resolving.WhenResolved.Wait(MediumNonDbgTimeout);
|
||||
}
|
||||
catch
|
||||
{
|
||||
success = false;
|
||||
}
|
||||
|
||||
if (!success)
|
||||
{
|
||||
if (++retry == 5)
|
||||
{
|
||||
@ -917,13 +929,24 @@ namespace Capnp.Net.Runtime.Tests
|
||||
label:
|
||||
using (var client = new TcpRpcClient("localhost", TcpPort))
|
||||
{
|
||||
|
||||
Assert.IsTrue(client.WhenConnected.Wait(MediumNonDbgTimeout));
|
||||
|
||||
using (var main = client.GetMain<ITestMoreStuff>())
|
||||
{
|
||||
var resolving = main as IResolvingCapability;
|
||||
if (!resolving.WhenResolved.Wait(MediumNonDbgTimeout))
|
||||
|
||||
bool success;
|
||||
|
||||
try
|
||||
{
|
||||
success = resolving.WhenResolved.Wait(MediumNonDbgTimeout);
|
||||
}
|
||||
catch
|
||||
{
|
||||
success = false;
|
||||
}
|
||||
|
||||
if (!success)
|
||||
{
|
||||
if (++retry == 5)
|
||||
{
|
||||
|
@ -3,6 +3,7 @@ using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
@ -97,7 +98,14 @@ namespace Capnp.Rpc
|
||||
{
|
||||
_exportTable.Clear();
|
||||
_revExportTable.Clear();
|
||||
_questionTable.Clear();
|
||||
|
||||
foreach (var question in _questionTable.Values.ToList())
|
||||
{
|
||||
question.OnException(new RpcException("RPC connection is broken. Task would never return."));
|
||||
}
|
||||
|
||||
Debug.Assert(_questionTable.Count == 0);
|
||||
|
||||
_answerTable.Clear();
|
||||
_pendingDisembargos.Clear();
|
||||
}
|
||||
|
@ -38,9 +38,15 @@ namespace Capnp.Rpc
|
||||
{
|
||||
async void SetupCancellation()
|
||||
{
|
||||
using (var registration = cancellationToken.Register(promisedAnswer.Dispose))
|
||||
try
|
||||
{
|
||||
using (var registration = cancellationToken.Register(promisedAnswer.Dispose))
|
||||
{
|
||||
await promisedAnswer.WhenReturned;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
await promisedAnswer.WhenReturned;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user