Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-11-12 17:01:08 +0300
committerAnna Henningsen <anna@addaleax.net>2019-11-19 15:47:33 +0300
commita489583eda4d7cebc06516834b31dc2a4cedb1b6 (patch)
tree8ead818f1ed28ce7c8965917209abc8d5b85bcb0 /src/cares_wrap.cc
parentc0b5e6fd4b87d1e61151b77b3ec10e6650f5153b (diff)
src: remove keep alive option from SetImmediate()
This is no longer necessary now that the copyable `BaseObjectPtr` is available (as opposed to the only-movable `v8::Global`). PR-URL: https://github.com/nodejs/node/pull/30374 Refs: https://github.com/nodejs/quic/pull/141 Refs: https://github.com/nodejs/quic/pull/149 Refs: https://github.com/nodejs/quic/pull/141 Refs: https://github.com/nodejs/quic/pull/165 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com>
Diffstat (limited to 'src/cares_wrap.cc')
-rw-r--r--src/cares_wrap.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc
index ee521ce64a0..1fb0f47dd80 100644
--- a/src/cares_wrap.cc
+++ b/src/cares_wrap.cc
@@ -627,8 +627,6 @@ class QueryWrap : public AsyncWrap {
} else {
Parse(response_data_->host.get());
}
-
- delete this;
}
void* MakeCallbackPointer() {
@@ -686,9 +684,13 @@ class QueryWrap : public AsyncWrap {
}
void QueueResponseCallback(int status) {
- env()->SetImmediate([this](Environment*) {
+ BaseObjectPtr<QueryWrap> strong_ref{this};
+ env()->SetImmediate([this, strong_ref](Environment*) {
AfterResponse();
- }, object());
+
+ // Delete once strong_ref goes out of scope.
+ Detach();
+ });
channel_->set_query_last_ok(status != ARES_ECONNREFUSED);
channel_->ModifyActivityQueryCount(-1);