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>
This commit is contained in:
Anna Henningsen committed 2017-08-12 22:00:26 +02:00
1 parent b87fae927d
commit d7d22ead2b
1 file changed
+5 -1
+5 -1
View File
@@ -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();