From 97c2c2d12754fa874215ef505a5b19bf71100c4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6llner?= Date: Thu, 22 Aug 2019 22:17:12 +0200 Subject: [PATCH] Troublehsooting ReleaseOnCancelClient --- Capnp.Net.Runtime.Tests/TcpRpcInterop.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Capnp.Net.Runtime.Tests/TcpRpcInterop.cs b/Capnp.Net.Runtime.Tests/TcpRpcInterop.cs index 8316d00..4156687 100644 --- a/Capnp.Net.Runtime.Tests/TcpRpcInterop.cs +++ b/Capnp.Net.Runtime.Tests/TcpRpcInterop.cs @@ -308,6 +308,9 @@ namespace Capnp.Net.Runtime.Tests --handleCount; break; + case "getCallSequence": + break; + default: Assert.Fail("Unexpected output"); break; @@ -318,12 +321,13 @@ namespace Capnp.Net.Runtime.Tests } var verifyOutputTask = VerifyOutput(); + var taskList = new List(); for (int i = 0; i < iterationCount; i++) { var task = main.GetHandle(default); Impatient.GetAnswer(task).Dispose(); - task.ContinueWith(t => + taskList.Add(task.ContinueWith(t => { try { @@ -332,9 +336,19 @@ namespace Capnp.Net.Runtime.Tests catch (TaskCanceledException) { } - }); + })); } + // Ensure that all answers either return (probably in canceled state) + Assert.IsTrue(Task.WhenAll(taskList).Wait(LargeNonDbgTimeout)); + + // Not part of original test. "Terminate" sequence with + // call to some different operation: getCallSequence + // Motivation: Cancelling the GetHandle request immediately after sending it might seduce the + // remote RPC implementation to immediately discard the request, before even calling the server + // method. => Cannot rely on receiving *exactly* 2*iterationCount outputs. + var term = main.GetCallSequence(0, default); + Assert.IsTrue(verifyOutputTask.Wait(LargeNonDbgTimeout)); // Not part of original test. Ensure that there is no unwanted extra output