From aeea2f2203a96c14749ee59a9818ee85a99ea4cd Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 21 May 2015 13:54:42 -0700 Subject: Fix shutdown crash in async streaming test --- test/cpp/qps/server_async.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc index 58499f345f..beb43acb6a 100644 --- a/test/cpp/qps/server_async.cc +++ b/test/cpp/qps/server_async.cc @@ -99,12 +99,15 @@ class AsyncQpsServerTest : public Server { while (srv_cq_->Next(&got_tag, &ok)) { ServerRpcContext *ctx = detag(got_tag); // The tag is a pointer to an RPC context to invoke - if (ctx->RunNextState(ok) == false) { + bool still_going = ctx->RunNextState(ok); + std::lock_guard g(shutdown_mutex_); + if (!shutdown_) { // this RPC context is done, so refresh it - std::lock_guard g(shutdown_mutex_); - if (!shutdown_) { + if (!still_going) { ctx->Reset(); } + } else { + return; } } return; @@ -116,11 +119,14 @@ class AsyncQpsServerTest : public Server { { std::lock_guard g(shutdown_mutex_); shutdown_ = true; - srv_cq_->Shutdown(); } for (auto thr = threads_.begin(); thr != threads_.end(); thr++) { thr->join(); } + srv_cq_->Shutdown(); + bool ok; + void *got_tag; + while (srv_cq_->Next(&got_tag, &ok)); while (!contexts_.empty()) { delete contexts_.front(); contexts_.pop_front(); -- cgit v1.2.3 From 8ebcec484fccefc1538854f8f0d1beadd5c0e720 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 21 May 2015 13:55:22 -0700 Subject: clang-format --- test/cpp/qps/server_async.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc index beb43acb6a..b9998405f6 100644 --- a/test/cpp/qps/server_async.cc +++ b/test/cpp/qps/server_async.cc @@ -126,7 +126,8 @@ class AsyncQpsServerTest : public Server { srv_cq_->Shutdown(); bool ok; void *got_tag; - while (srv_cq_->Next(&got_tag, &ok)); + while (srv_cq_->Next(&got_tag, &ok)) + ; while (!contexts_.empty()) { delete contexts_.front(); contexts_.pop_front(); -- cgit v1.2.3 From 2fb16aafa3254b42c4d53b60c0782fb627154085 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 22 May 2015 09:49:06 -0700 Subject: Fixed ordering assumptions in server_streaming interop test --- src/node/interop/interop_client.js | 6 ++++-- src/node/src/client.js | 8 +++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/node/interop/interop_client.js b/src/node/interop/interop_client.js index 80f811901c..455055d9f3 100644 --- a/src/node/interop/interop_client.js +++ b/src/node/interop/interop_client.js @@ -154,13 +154,15 @@ function serverStreaming(client, done) { arg.response_parameters[resp_index].size); resp_index += 1; }); - call.on('status', function(status) { - assert.strictEqual(status.code, grpc.status.OK); + call.on('end', function() { assert.strictEqual(resp_index, 4); if (done) { done(); } }); + call.on('status', function(status) { + assert.strictEqual(status.code, grpc.status.OK); + }); } /** diff --git a/src/node/src/client.js b/src/node/src/client.js index efec05bbf3..be1e534707 100644 --- a/src/node/src/client.js +++ b/src/node/src/client.js @@ -81,7 +81,7 @@ function _write(chunk, encoding, callback) { batch[grpc.opType.SEND_MESSAGE] = this.serialize(chunk); this.call.startBatch(batch, function(err, event) { if (err) { - // Something has gone wrong. Stop writing by failing to call callback + callback(err); return; } callback(); @@ -125,11 +125,9 @@ function _read(size) { self.finished = true; return; } - if (self.finished) { - self.push(null); - return; - } var data = event.read; + var deserialized = self.deserialize(data); + console.log(deserialized); if (self.push(self.deserialize(data)) && data !== null) { var read_batch = {}; read_batch[grpc.opType.RECV_MESSAGE] = true; -- cgit v1.2.3 From fe29b6dea1db08ea4edd1748f29dfc6cd35a33fd Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 22 May 2015 09:50:41 -0700 Subject: Removed debug log --- src/node/src/client.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/node/src/client.js b/src/node/src/client.js index be1e534707..c9c0318b6d 100644 --- a/src/node/src/client.js +++ b/src/node/src/client.js @@ -126,8 +126,6 @@ function _read(size) { return; } var data = event.read; - var deserialized = self.deserialize(data); - console.log(deserialized); if (self.push(self.deserialize(data)) && data !== null) { var read_batch = {}; read_batch[grpc.opType.RECV_MESSAGE] = true; -- cgit v1.2.3 From 6d1a8449d1f485d6d037b397a5df7ac42218c5e9 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 22 May 2015 10:29:05 -0700 Subject: Coalesced redundant code --- src/node/src/client.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/node/src/client.js b/src/node/src/client.js index c9c0318b6d..9a50bf24d9 100644 --- a/src/node/src/client.js +++ b/src/node/src/client.js @@ -80,11 +80,7 @@ function _write(chunk, encoding, callback) { var batch = {}; batch[grpc.opType.SEND_MESSAGE] = this.serialize(chunk); this.call.startBatch(batch, function(err, event) { - if (err) { - callback(err); - return; - } - callback(); + callback(err); }); } -- cgit v1.2.3 From b4f244f0da5c342f6a62db02bf32bb6c4e695d4d Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 22 May 2015 11:06:11 -0700 Subject: Reverted change to _write in client.js --- src/node/src/client.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/node/src/client.js b/src/node/src/client.js index 9a50bf24d9..65339406b2 100644 --- a/src/node/src/client.js +++ b/src/node/src/client.js @@ -80,7 +80,11 @@ function _write(chunk, encoding, callback) { var batch = {}; batch[grpc.opType.SEND_MESSAGE] = this.serialize(chunk); this.call.startBatch(batch, function(err, event) { - callback(err); + if (err) { + // Something has gone wrong. Stop writing by failing to call callback + return; + } + callback(); }); } -- cgit v1.2.3