aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/node
diff options
context:
space:
mode:
authorGravatar murgatroid99 <mlumish@google.com>2017-04-11 14:34:04 -0700
committerGravatar murgatroid99 <mlumish@google.com>2017-04-11 16:15:32 -0700
commit017a335d2b1170dafe4731c69c4fec9fad42a4ba (patch)
treef477c3d19556fea2a2e7fed65b99b295892cf828 /src/node
parent803392e9f14baeedfe37308cf0ff47978bf3f5e6 (diff)
Only delete core-level server if shutdown was successful
Diffstat (limited to 'src/node')
-rw-r--r--src/node/ext/call.cc19
-rw-r--r--src/node/ext/call.h2
-rw-r--r--src/node/ext/server.cc8
-rw-r--r--src/node/ext/server_uv.cc4
4 files changed, 19 insertions, 14 deletions
diff --git a/src/node/ext/call.cc b/src/node/ext/call.cc
index bb11cfb83a..bd60775aad 100644
--- a/src/node/ext/call.cc
+++ b/src/node/ext/call.cc
@@ -217,7 +217,7 @@ class SendMetadataOp : public Op {
bool IsFinalOp() {
return false;
}
- void OnComplete() {
+ void OnComplete(bool success) {
}
protected:
std::string GetTypeString() const {
@@ -262,7 +262,7 @@ class SendMessageOp : public Op {
bool IsFinalOp() {
return false;
}
- void OnComplete() {
+ void OnComplete(bool success) {
}
protected:
std::string GetTypeString() const {
@@ -284,7 +284,7 @@ class SendClientCloseOp : public Op {
bool IsFinalOp() {
return false;
}
- void OnComplete() {
+ void OnComplete(bool success) {
}
protected:
std::string GetTypeString() const {
@@ -355,7 +355,7 @@ class SendServerStatusOp : public Op {
bool IsFinalOp() {
return true;
}
- void OnComplete() {
+ void OnComplete(bool success) {
}
protected:
std::string GetTypeString() const {
@@ -389,7 +389,7 @@ class GetMetadataOp : public Op {
bool IsFinalOp() {
return false;
}
- void OnComplete() {
+ void OnComplete(bool success) {
}
protected:
@@ -423,7 +423,7 @@ class ReadMessageOp : public Op {
bool IsFinalOp() {
return false;
}
- void OnComplete() {
+ void OnComplete(bool success) {
}
protected:
@@ -466,7 +466,7 @@ class ClientStatusOp : public Op {
bool IsFinalOp() {
return true;
}
- void OnComplete() {
+ void OnComplete(bool success) {
}
protected:
std::string GetTypeString() const {
@@ -492,7 +492,7 @@ class ServerCloseResponseOp : public Op {
bool IsFinalOp() {
return false;
}
- void OnComplete() {
+ void OnComplete(bool success) {
}
protected:
@@ -532,11 +532,12 @@ void CompleteTag(void *tag, const char *error_message) {
Local<Value> argv[] = {Nan::Error(error_message)};
callback->Call(1, argv);
}
+ bool success = (error_message == NULL);
bool is_final_op = false;
for (vector<unique_ptr<Op> >::iterator it = tag_struct->ops->begin();
it != tag_struct->ops->end(); ++it) {
Op *op_ptr = it->get();
- op_ptr->OnComplete();
+ op_ptr->OnComplete(success);
if (op_ptr->IsFinalOp()) {
is_final_op = true;
}
diff --git a/src/node/ext/call.h b/src/node/ext/call.h
index b38f50060c..340e32682b 100644
--- a/src/node/ext/call.h
+++ b/src/node/ext/call.h
@@ -106,7 +106,7 @@ class Op {
virtual ~Op();
v8::Local<v8::Value> GetOpType() const;
virtual bool IsFinalOp() = 0;
- virtual void OnComplete() = 0;
+ virtual void OnComplete(bool success) = 0;
protected:
virtual std::string GetTypeString() const = 0;
diff --git a/src/node/ext/server.cc b/src/node/ext/server.cc
index 2d017dd048..5384305631 100644
--- a/src/node/ext/server.cc
+++ b/src/node/ext/server.cc
@@ -117,7 +117,7 @@ class NewCallOp : public Op {
bool IsFinalOp() {
return false;
}
- void OnComplete() {
+ void OnComplete(bool success) {
}
grpc_call *call;
@@ -143,8 +143,10 @@ class TryShutdownOp: public Op {
bool IsFinalOp() {
return false;
}
- void OnComplete() {
- server->DestroyWrappedServer();
+ void OnComplete(bool success) {
+ if (success) {
+ server->DestroyWrappedServer();
+ }
}
protected:
std::string GetTypeString() const { return "try_shutdown"; }
diff --git a/src/node/ext/server_uv.cc b/src/node/ext/server_uv.cc
index 6a31b89249..789938318e 100644
--- a/src/node/ext/server_uv.cc
+++ b/src/node/ext/server_uv.cc
@@ -76,7 +76,9 @@ class ServerShutdownOp : public Op {
bool IsFinalOp() {
return false;
}
- void OnComplete() {
+ void OnComplete(bool success) {
+ /* Because cancel_all_calls was called, we assume that shutdown_and_notify
+ completes successfully */
grpc_server_destroy(server);
}