mirror of
https://github.com/FabInfra/capnproto-dotnetcore_Runtime.git
synced 2025-03-13 23:31:50 +01:00
Removed debugging aids, fixed Random non-reentrancy, increased ReleaseOnCancelClient timeout
This commit is contained in:
parent
fecfa94433
commit
20d480a770
@ -259,7 +259,7 @@ namespace Capnp.Net.Runtime.Tests
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod, Timeout(10000)]
|
[TestMethod, Timeout(20000)]
|
||||||
public void ReleaseOnCancelClient()
|
public void ReleaseOnCancelClient()
|
||||||
{
|
{
|
||||||
// Since we have a threaded model, there is no way to deterministically provoke the situation
|
// Since we have a threaded model, there is no way to deterministically provoke the situation
|
||||||
@ -774,7 +774,9 @@ namespace Capnp.Net.Runtime.Tests
|
|||||||
|
|
||||||
var cap = new TestCallOrderImpl();
|
var cap = new TestCallOrderImpl();
|
||||||
cap.CountToDispose = 6;
|
cap.CountToDispose = 6;
|
||||||
|
#if DEBUG_DISPOSE
|
||||||
Skeleton.BeginAssertNotDisposed(cap);
|
Skeleton.BeginAssertNotDisposed(cap);
|
||||||
|
#endif
|
||||||
var earlyCall = main.GetCallSequence(0, default);
|
var earlyCall = main.GetCallSequence(0, default);
|
||||||
|
|
||||||
var echo = main.Echo(cap, default);
|
var echo = main.Echo(cap, default);
|
||||||
@ -809,7 +811,9 @@ namespace Capnp.Net.Runtime.Tests
|
|||||||
Assert.AreEqual(4u, call4.Result);
|
Assert.AreEqual(4u, call4.Result);
|
||||||
Assert.AreEqual(5u, call5.Result);
|
Assert.AreEqual(5u, call5.Result);
|
||||||
|
|
||||||
|
#if DEBUG_DISPOSE
|
||||||
Skeleton.EndAssertNotDisposed(cap);
|
Skeleton.EndAssertNotDisposed(cap);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,11 +234,11 @@ namespace Capnp.Rpc
|
|||||||
|
|
||||||
PendingQuestion AllocateQuestion(ConsumedCapability target, SerializerState inParams)
|
PendingQuestion AllocateQuestion(ConsumedCapability target, SerializerState inParams)
|
||||||
{
|
{
|
||||||
uint questionId = RandId();
|
|
||||||
var question = new PendingQuestion(this, questionId, target, inParams);
|
|
||||||
|
|
||||||
lock (_reentrancyBlocker)
|
lock (_reentrancyBlocker)
|
||||||
{
|
{
|
||||||
|
uint questionId = RandId();
|
||||||
|
var question = new PendingQuestion(this, questionId, target, inParams);
|
||||||
|
|
||||||
while (!_questionTable.ReplacementTryAdd(questionId, question))
|
while (!_questionTable.ReplacementTryAdd(questionId, question))
|
||||||
{
|
{
|
||||||
questionId = RandId();
|
questionId = RandId();
|
||||||
@ -246,9 +246,9 @@ namespace Capnp.Rpc
|
|||||||
question = new PendingQuestion(this, questionId, target, inParams);
|
question = new PendingQuestion(this, questionId, target, inParams);
|
||||||
oldQuestion.Dispose();
|
oldQuestion.Dispose();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return question;
|
return question;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeleteQuestion(uint id, PendingQuestion question)
|
void DeleteQuestion(uint id, PendingQuestion question)
|
||||||
|
@ -29,7 +29,9 @@ namespace Capnp.Rpc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if DEBUG_DISPOSE
|
||||||
const int NoDisposeFlag = 0x4000000;
|
const int NoDisposeFlag = 0x4000000;
|
||||||
|
#endif
|
||||||
|
|
||||||
static readonly ConditionalWeakTable<object, Skeleton> _implMap =
|
static readonly ConditionalWeakTable<object, Skeleton> _implMap =
|
||||||
new ConditionalWeakTable<object, Skeleton>();
|
new ConditionalWeakTable<object, Skeleton>();
|
||||||
@ -61,6 +63,7 @@ namespace Capnp.Rpc
|
|||||||
return new SkeletonRelinquisher(GetOrCreateSkeleton(impl, true));
|
return new SkeletonRelinquisher(GetOrCreateSkeleton(impl, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if DEBUG_DISPOSE
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This DEBUG-only diagnostic method states that the Skeleton corresponding to a given capability is not expected to
|
/// This DEBUG-only diagnostic method states that the Skeleton corresponding to a given capability is not expected to
|
||||||
/// be disposed until the next call to EndAssertNotDisposed().
|
/// be disposed until the next call to EndAssertNotDisposed().
|
||||||
@ -81,6 +84,7 @@ namespace Capnp.Rpc
|
|||||||
{
|
{
|
||||||
GetOrCreateSkeleton(impl, false).EndAssertNotDisposed();
|
GetOrCreateSkeleton(impl, false).EndAssertNotDisposed();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int _refCount = 0;
|
int _refCount = 0;
|
||||||
|
|
||||||
@ -99,6 +103,7 @@ namespace Capnp.Rpc
|
|||||||
Interlocked.Increment(ref _refCount);
|
Interlocked.Increment(ref _refCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if DEBUG_DISPOSE
|
||||||
internal void BeginAssertNotDisposed()
|
internal void BeginAssertNotDisposed()
|
||||||
{
|
{
|
||||||
if ((Interlocked.Add(ref _refCount, NoDisposeFlag) & NoDisposeFlag) == 0)
|
if ((Interlocked.Add(ref _refCount, NoDisposeFlag) & NoDisposeFlag) == 0)
|
||||||
@ -113,6 +118,7 @@ namespace Capnp.Rpc
|
|||||||
throw new InvalidOperationException("Flag already cleared. State is now broken.");
|
throw new InvalidOperationException("Flag already cleared. State is now broken.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
internal void Relinquish()
|
internal void Relinquish()
|
||||||
{
|
{
|
||||||
@ -120,8 +126,10 @@ namespace Capnp.Rpc
|
|||||||
|
|
||||||
if (0 == count)
|
if (0 == count)
|
||||||
{
|
{
|
||||||
|
#if DEBUG_DISPOSE
|
||||||
if ((count & NoDisposeFlag) != 0)
|
if ((count & NoDisposeFlag) != 0)
|
||||||
throw new InvalidOperationException("Unexpected Skeleton disposal");
|
throw new InvalidOperationException("Unexpected Skeleton disposal");
|
||||||
|
#endif
|
||||||
|
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user