Skip to content
Snippets Groups Projects
Commit 2a4ea2da authored by murgatroid99's avatar murgatroid99
Browse files

Node: consolidate call destruction logic

parent 130568e5
No related branches found
No related tags found
No related merge requests found
...@@ -515,16 +515,20 @@ void DestroyTag(void *tag) { ...@@ -515,16 +515,20 @@ void DestroyTag(void *tag) {
delete tag_struct; delete tag_struct;
} }
void Call::DestroyCall() {
if (this->wrapped_call != NULL) {
grpc_call_destroy(this->wrapped_call);
this->wrapped_call = NULL;
}
}
Call::Call(grpc_call *call) : wrapped_call(call), Call::Call(grpc_call *call) : wrapped_call(call),
pending_batches(0), pending_batches(0),
has_final_op_completed(false) { has_final_op_completed(false) {
} }
Call::~Call() { Call::~Call() {
if (wrapped_call != NULL) { DestroyCall();
grpc_call_destroy(wrapped_call);
wrapped_call = NULL;
}
} }
void Call::Init(Local<Object> exports) { void Call::Init(Local<Object> exports) {
...@@ -570,10 +574,8 @@ void Call::CompleteBatch(bool is_final_op) { ...@@ -570,10 +574,8 @@ void Call::CompleteBatch(bool is_final_op) {
this->has_final_op_completed = true; this->has_final_op_completed = true;
} }
this->pending_batches--; this->pending_batches--;
if (this->has_final_op_completed && this->pending_batches == 0 && if (this->has_final_op_completed && this->pending_batches == 0) {
this->wrapped_call != NULL) { this->DestroyCall();
grpc_call_destroy(this->wrapped_call);
this->wrapped_call = NULL;
} }
} }
......
...@@ -76,6 +76,8 @@ class Call : public Nan::ObjectWrap { ...@@ -76,6 +76,8 @@ class Call : public Nan::ObjectWrap {
Call(const Call &); Call(const Call &);
Call &operator=(const Call &); Call &operator=(const Call &);
void DestroyCall();
static NAN_METHOD(New); static NAN_METHOD(New);
static NAN_METHOD(StartBatch); static NAN_METHOD(StartBatch);
static NAN_METHOD(Cancel); static NAN_METHOD(Cancel);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment