Only delete core-level server if shutdown was successful

This commit is contained in:
murgatroid99 2017-04-11 14:34:04 -07:00
parent 902527e529
commit 8b7472fbec
4 changed files with 19 additions and 14 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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"; }

View File

@ -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);
}