diff options
Diffstat (limited to 'src/csharp/Grpc.Core/Internal/AsyncCallBase.cs')
-rw-r--r-- | src/csharp/Grpc.Core/Internal/AsyncCallBase.cs | 41 |
1 files changed, 15 insertions, 26 deletions
diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs index 9f9d260e7e..8668903f6e 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs @@ -181,19 +181,16 @@ namespace Grpc.Core.Internal /// </summary> protected bool ReleaseResourcesIfPossible() { - using (Profilers.ForCurrentThread().NewScope("AsyncCallBase.ReleaseResourcesIfPossible")) + if (!disposed && call != null) { - if (!disposed && call != null) + bool noMoreSendCompletions = streamingWriteTcs == null && (halfcloseRequested || cancelRequested || finished); + if (noMoreSendCompletions && readingDone && finished) { - bool noMoreSendCompletions = streamingWriteTcs == null && (halfcloseRequested || cancelRequested || finished); - if (noMoreSendCompletions && readingDone && finished) - { - ReleaseResources(); - return true; - } + ReleaseResources(); + return true; } - return false; } + return false; } protected abstract bool IsClient @@ -229,28 +226,20 @@ namespace Grpc.Core.Internal protected byte[] UnsafeSerialize(TWrite msg) { - using (Profilers.ForCurrentThread().NewScope("AsyncCallBase.UnsafeSerialize")) - { - return serializer(msg); - } + return serializer(msg); } protected Exception TryDeserialize(byte[] payload, out TRead msg) { - using (Profilers.ForCurrentThread().NewScope("AsyncCallBase.TryDeserialize")) + try { - try - { - - msg = deserializer(payload); - return null; - - } - catch (Exception e) - { - msg = default(TRead); - return e; - } + msg = deserializer(payload); + return null; + } + catch (Exception e) + { + msg = default(TRead); + return e; } } |