From e339f6feecf943c282ccc5efe4500a7d3d4b660a Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Wed, 23 Sep 2015 11:38:39 -0700 Subject: [PATCH 01/48] Fixed hang when using Node gRPC with other async operations --- src/node/ext/completion_queue_async_worker.cc | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/node/ext/completion_queue_async_worker.cc b/src/node/ext/completion_queue_async_worker.cc index bf2cd946a5c..efc611b8b78 100644 --- a/src/node/ext/completion_queue_async_worker.cc +++ b/src/node/ext/completion_queue_async_worker.cc @@ -53,6 +53,9 @@ using v8::Value; grpc_completion_queue *CompletionQueueAsyncWorker::queue; +// Invariants: current_threads <= max_queue_threads +// (current_threads == max_queue_threads) || (waiting_next_calls == 0) + int CompletionQueueAsyncWorker::current_threads; int CompletionQueueAsyncWorker::waiting_next_calls; @@ -74,11 +77,15 @@ grpc_completion_queue *CompletionQueueAsyncWorker::GetQueue() { return queue; } void CompletionQueueAsyncWorker::Next() { NanScope(); if (current_threads < max_queue_threads) { + current_threads += 1; CompletionQueueAsyncWorker *worker = new CompletionQueueAsyncWorker(); NanAsyncQueueWorker(worker); } else { waiting_next_calls += 1; } + GPR_ASSERT(current_threads <= max_queue_threads); + GPR_ASSERT((current_threads == max_queue_threads) || + (waiting_next_calls == 0)); } void CompletionQueueAsyncWorker::Init(Handle exports) { @@ -92,11 +99,15 @@ void CompletionQueueAsyncWorker::HandleOKCallback() { NanScope(); if (waiting_next_calls > 0) { waiting_next_calls -= 1; + // Old worker removed, new worker added. current_threads += 0 CompletionQueueAsyncWorker *worker = new CompletionQueueAsyncWorker(); NanAsyncQueueWorker(worker); } else { current_threads -= 1; } + GPR_ASSERT(current_threads <= max_queue_threads); + GPR_ASSERT((current_threads == max_queue_threads) || + (waiting_next_calls == 0)); NanCallback *callback = GetTagCallback(result.tag); Handle argv[] = {NanNull(), GetTagNodeValue(result.tag)}; callback->Call(2, argv); @@ -106,6 +117,17 @@ void CompletionQueueAsyncWorker::HandleOKCallback() { void CompletionQueueAsyncWorker::HandleErrorCallback() { NanScope(); + if (waiting_next_calls > 0) { + waiting_next_calls -= 1; + // Old worker removed, new worker added. current_threads += 0 + CompletionQueueAsyncWorker *worker = new CompletionQueueAsyncWorker(); + NanAsyncQueueWorker(worker); + } else { + current_threads -= 1; + } + GPR_ASSERT(current_threads <= max_queue_threads); + GPR_ASSERT((current_threads == max_queue_threads) || + (waiting_next_calls == 0)); NanCallback *callback = GetTagCallback(result.tag); Handle argv[] = {NanError(ErrorMessage())}; From ad88f57ae9e43b1d5bcbb53e3baeefff6447121f Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 23 Sep 2015 12:23:04 -0700 Subject: [PATCH 02/48] update C# examples to 0.7.1 --- examples/csharp/helloworld/.nuget/packages.config | 2 +- examples/csharp/helloworld/Greeter/Greeter.csproj | 14 +++++++------- examples/csharp/helloworld/Greeter/packages.config | 6 +++--- .../helloworld/GreeterClient/GreeterClient.csproj | 14 +++++++------- .../helloworld/GreeterClient/packages.config | 6 +++--- .../helloworld/GreeterServer/GreeterServer.csproj | 14 +++++++------- .../helloworld/GreeterServer/packages.config | 6 +++--- examples/csharp/route_guide/.nuget/packages.config | 2 +- .../route_guide/RouteGuide/RouteGuide.csproj | 14 +++++++------- .../csharp/route_guide/RouteGuide/packages.config | 6 +++--- .../RouteGuideClient/RouteGuideClient.csproj | 14 +++++++------- .../route_guide/RouteGuideClient/packages.config | 6 +++--- .../RouteGuideServer/RouteGuideServer.csproj | 14 +++++++------- .../route_guide/RouteGuideServer/packages.config | 6 +++--- 14 files changed, 62 insertions(+), 62 deletions(-) diff --git a/examples/csharp/helloworld/.nuget/packages.config b/examples/csharp/helloworld/.nuget/packages.config index e2879c18932..1c1f118d466 100644 --- a/examples/csharp/helloworld/.nuget/packages.config +++ b/examples/csharp/helloworld/.nuget/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/examples/csharp/helloworld/Greeter/Greeter.csproj b/examples/csharp/helloworld/Greeter/Greeter.csproj index 3d92c4bf25a..2ae8620267f 100644 --- a/examples/csharp/helloworld/Greeter/Greeter.csproj +++ b/examples/csharp/helloworld/Greeter/Greeter.csproj @@ -1,6 +1,6 @@  - + @@ -13,7 +13,7 @@ Greeter Greeter v4.5 - 3ef64a6a + e423e365 true @@ -37,9 +37,9 @@ ..\packages\Google.Protobuf.3.0.0-alpha4\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll - + False - ..\packages\Grpc.Core.0.7.0\lib\net45\Grpc.Core.dll + ..\packages\Grpc.Core.0.7.1\lib\net45\Grpc.Core.dll @@ -65,10 +65,10 @@ - - + + - + \ No newline at end of file diff --git a/examples/csharp/helloworld/Greeter/packages.config b/examples/csharp/helloworld/Greeter/packages.config index 1273624cbd0..c0f73879160 100644 --- a/examples/csharp/helloworld/Greeter/packages.config +++ b/examples/csharp/helloworld/Greeter/packages.config @@ -1,10 +1,10 @@  - - + + - + \ No newline at end of file diff --git a/examples/csharp/helloworld/GreeterClient/GreeterClient.csproj b/examples/csharp/helloworld/GreeterClient/GreeterClient.csproj index 7874172bf26..af330f2b905 100644 --- a/examples/csharp/helloworld/GreeterClient/GreeterClient.csproj +++ b/examples/csharp/helloworld/GreeterClient/GreeterClient.csproj @@ -1,6 +1,6 @@  - + @@ -13,7 +13,7 @@ GreeterClient GreeterClient v4.5 - c4057b0a + 2dcf22af true @@ -37,9 +37,9 @@ ..\packages\Google.Protobuf.3.0.0-alpha4\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll - + False - ..\packages\Grpc.Core.0.7.0\lib\net45\Grpc.Core.dll + ..\packages\Grpc.Core.0.7.1\lib\net45\Grpc.Core.dll @@ -68,10 +68,10 @@ - - + + - + \ No newline at end of file diff --git a/examples/csharp/helloworld/GreeterClient/packages.config b/examples/csharp/helloworld/GreeterClient/packages.config index 1273624cbd0..c0f73879160 100644 --- a/examples/csharp/helloworld/GreeterClient/packages.config +++ b/examples/csharp/helloworld/GreeterClient/packages.config @@ -1,10 +1,10 @@  - - + + - + \ No newline at end of file diff --git a/examples/csharp/helloworld/GreeterServer/GreeterServer.csproj b/examples/csharp/helloworld/GreeterServer/GreeterServer.csproj index d1db2f4773b..752f32828b0 100644 --- a/examples/csharp/helloworld/GreeterServer/GreeterServer.csproj +++ b/examples/csharp/helloworld/GreeterServer/GreeterServer.csproj @@ -1,6 +1,6 @@  - + @@ -13,7 +13,7 @@ GreeterServer GreeterServer v4.5 - cc15afe5 + 53a3a588 true @@ -37,9 +37,9 @@ ..\packages\Google.Protobuf.3.0.0-alpha4\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll - + False - ..\packages\Grpc.Core.0.7.0\lib\net45\Grpc.Core.dll + ..\packages\Grpc.Core.0.7.1\lib\net45\Grpc.Core.dll @@ -68,10 +68,10 @@ - - + + - + \ No newline at end of file diff --git a/examples/csharp/helloworld/GreeterServer/packages.config b/examples/csharp/helloworld/GreeterServer/packages.config index 1273624cbd0..c0f73879160 100644 --- a/examples/csharp/helloworld/GreeterServer/packages.config +++ b/examples/csharp/helloworld/GreeterServer/packages.config @@ -1,10 +1,10 @@  - - + + - + \ No newline at end of file diff --git a/examples/csharp/route_guide/.nuget/packages.config b/examples/csharp/route_guide/.nuget/packages.config index e2879c18932..1c1f118d466 100644 --- a/examples/csharp/route_guide/.nuget/packages.config +++ b/examples/csharp/route_guide/.nuget/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj b/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj index 302a783aa46..f3342229d42 100644 --- a/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj +++ b/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj @@ -1,6 +1,6 @@  - + @@ -14,7 +14,7 @@ RouteGuide v4.5 512 - 443bbc38 + 256a7eeb true @@ -37,9 +37,9 @@ ..\packages\Google.Protobuf.3.0.0-alpha4\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll - + False - ..\packages\Grpc.Core.0.7.0\lib\net45\Grpc.Core.dll + ..\packages\Grpc.Core.0.7.1\lib\net45\Grpc.Core.dll False @@ -77,12 +77,12 @@ - - + + - +