Troubleshooting

This commit is contained in:
Christian Köllner 2019-08-25 17:52:35 +02:00
parent 0140f21cc4
commit 198f778d65
3 changed files with 24 additions and 15 deletions

View File

@ -33,14 +33,26 @@ namespace Capnp.Rpc
// Really weird: We'd expect AwaitAnswer() to initialize a new Task instance upon each invocation. // Really weird: We'd expect AwaitAnswer() to initialize a new Task instance upon each invocation.
// However, this does not seem to be always true (as indicated by CI test suite). An explanation might be // However, this does not seem to be always true (as indicated by CI test suite). An explanation might be
// that the underlying implementation recycles Task instances. Let's work around it. // that the underlying implementation recycles Task instances (um, really? doesn't make sense. But the
// obsevation doesn't make sense, either).
#if NETSTANDARD2_0 try
_taskTable.Remove(rtask); {
_taskTable.Add(rtask, promise); _taskTable.Add(rtask, promise);
#else }
_taskTable.AddOrUpdate(rtask, promise); catch (ArgumentException)
#endif {
// Force .NET to create a new Task instance
async Task<T> AwaitAgain()
{
return await rtask;
}
rtask = AwaitAgain();
_taskTable.Add(rtask, promise);
}
return rtask; return rtask;
} }

View File

@ -23,7 +23,6 @@ namespace Capnp.Rpc
// In order to distinguish state A from C, the member _refCount stores the reference count *plus one*. // In order to distinguish state A from C, the member _refCount stores the reference count *plus one*.
// Value 0 has the special meaning of being in state C. // Value 0 has the special meaning of being in state C.
int _refCount = 1; int _refCount = 1;
string _disposerStackTrace;
~RefCountingCapability() ~RefCountingCapability()
{ {
@ -37,6 +36,8 @@ namespace Capnp.Rpc
{ {
if (disposing) if (disposing)
{ {
_refCount = 0;
try try
{ {
ReleaseRemotely(); ReleaseRemotely();
@ -44,8 +45,6 @@ namespace Capnp.Rpc
catch catch
{ {
} }
_refCount = 0;
} }
else else
{ {
@ -69,7 +68,7 @@ namespace Capnp.Rpc
{ {
if (Interlocked.Increment(ref _refCount) <= 1) if (Interlocked.Increment(ref _refCount) <= 1)
{ {
throw new ObjectDisposedException(nameof(ConsumedCapability), _disposerStackTrace); throw new ObjectDisposedException(nameof(ConsumedCapability));
} }
} }
@ -77,8 +76,6 @@ namespace Capnp.Rpc
{ {
if (1 >= Interlocked.Decrement(ref _refCount)) if (1 >= Interlocked.Decrement(ref _refCount))
{ {
_disposerStackTrace = Environment.StackTrace;
Dispose(true); Dispose(true);
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
} }

View File

@ -38,10 +38,10 @@ build_script:
after_build: after_build:
# For once the build has completed # For once the build has completed
artifacts: artifacts:
- path: Capnp.Net.Runtime\bin\Debug - path: Capnp.Net.Runtime\bin\Debug\Capnp.Net.Runtime.$(appveyor_build_version).nupkg
name: Capnp.Net.Runtime_debug name: Capnp.Net.Runtime_debug
type: NuGetPackage type: NuGetPackage
- path: Capnp.Net.Runtime\bin\Release - path: Capnp.Net.Runtime\bin\Release\Capnp.Net.Runtime.$(appveyor_build_version).nupkg
name: Capnp.Net.Runtime name: Capnp.Net.Runtime
type: NuGetPackage type: NuGetPackage
- path: chocolatey\install\capnpc-csharp-win-x86.$(appveyor_build_version).nupkg - path: chocolatey\install\capnpc-csharp-win-x86.$(appveyor_build_version).nupkg