Skip to content

Commit

Permalink
src: add comments for cares library init refcount
Browse files Browse the repository at this point in the history
Ref: #14738
PR-URL: #14743
Reviewed-By: Timothy Gu <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Khaidi Chu <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
addaleax committed Aug 12, 2017
1 parent b87fae9 commit d7d22ea
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/cares_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit d7d22ea

Please sign in to comment.