We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4796fbc commit 1e3d0d2Copy full SHA for 1e3d0d2
1 file changed
src/cares_wrap.cc
@@ -489,6 +489,8 @@ void ChannelWrap::Setup() {
489
490
int r;
491
if (!library_inited_) {
492
+ // Multiple calls to ares_library_init() increase a reference counter,
493
+ // so this is a no-op except for the first call to it.
494
r = ares_library_init(ARES_LIB_INIT_ALL);
495
if (r != ARES_SUCCESS)
496
return env()->ThrowError(ToErrorCodeString(r));
@@ -516,8 +518,10 @@ void ChannelWrap::Setup() {
516
518
517
519
520
ChannelWrap::~ChannelWrap() {
- if (library_inited_)
521
+ if (library_inited_) {
522
+ // This decreases the reference counter increased by ares_library_init().
523
ares_library_cleanup();
524
+ }
525
526
ares_destroy(channel_);
527
CleanupTimer();
0 commit comments