summaryrefslogtreecommitdiff
path: root/src/cares_wrap.cc
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2017-08-10 16:56:04 +0200
committerAnna Henningsen <anna@addaleax.net>2017-08-11 21:33:37 +0200
commiteb8f574229bb7508d137790ff5b840408fe14832 (patch)
tree25ea8fda533cabf9768d247d33db1617d1515a04 /src/cares_wrap.cc
parent39c67f43a261ae9a6d805f7f6a93f3fb935f9077 (diff)
downloadandroid-node-v8-eb8f574229bb7508d137790ff5b840408fe14832.tar.gz
android-node-v8-eb8f574229bb7508d137790ff5b840408fe14832.tar.bz2
android-node-v8-eb8f574229bb7508d137790ff5b840408fe14832.zip
src: add comments for cares library init refcount
Ref: https://github.com/nodejs/node/pull/14738 PR-URL: https://github.com/nodejs/node/pull/14743 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/cares_wrap.cc')
-rw-r--r--src/cares_wrap.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc
index 53a005444c..7869651a45 100644
--- a/src/cares_wrap.cc
+++ b/src/cares_wrap.cc
@@ -489,6 +489,8 @@ void ChannelWrap::Setup() {
int r;
if (!library_inited_) {
+ // Multiple calls to ares_library_init() increase a reference counter,
+ // so this is a no-op except for the first call to it.
r = ares_library_init(ARES_LIB_INIT_ALL);
if (r != ARES_SUCCESS)
return env()->ThrowError(ToErrorCodeString(r));
@@ -516,8 +518,10 @@ void ChannelWrap::Setup() {
ChannelWrap::~ChannelWrap() {
- if (library_inited_)
+ if (library_inited_) {
+ // This decreases the reference counter increased by ares_library_init().
ares_library_cleanup();
+ }
ares_destroy(channel_);
CleanupTimer();