@@ -631,9 +631,14 @@ int ParseSoaReply(
631631}
632632} // anonymous namespace
633633
634- ChannelWrap::ChannelWrap (Environment* env, Local<Object> object, int timeout)
634+ ChannelWrap::ChannelWrap (
635+ Environment* env,
636+ Local<Object> object,
637+ int timeout,
638+ int tries)
635639 : AsyncWrap(env, object, PROVIDER_DNSCHANNEL),
636- timeout_ (timeout) {
640+ timeout_ (timeout),
641+ tries_(tries) {
637642 MakeWeak ();
638643
639644 Setup ();
@@ -647,11 +652,13 @@ void ChannelWrap::MemoryInfo(MemoryTracker* tracker) const {
647652
648653void ChannelWrap::New (const FunctionCallbackInfo<Value>& args) {
649654 CHECK (args.IsConstructCall ());
650- CHECK_EQ (args.Length (), 1 );
655+ CHECK_EQ (args.Length (), 2 );
651656 CHECK (args[0 ]->IsInt32 ());
657+ CHECK (args[1 ]->IsInt32 ());
652658 const int timeout = args[0 ].As <Int32>()->Value ();
659+ const int tries = args[1 ].As <Int32>()->Value ();
653660 Environment* env = Environment::GetCurrent (args);
654- new ChannelWrap (env, args.This (), timeout);
661+ new ChannelWrap (env, args.This (), timeout, tries );
655662}
656663
657664GetAddrInfoReqWrap::GetAddrInfoReqWrap (
@@ -704,6 +711,7 @@ void ChannelWrap::Setup() {
704711 options.sock_state_cb = ares_sockstate_cb;
705712 options.sock_state_cb_data = this ;
706713 options.timeout = timeout_;
714+ options.tries = tries_;
707715
708716 int r;
709717 if (!library_inited_) {
@@ -717,7 +725,8 @@ void ChannelWrap::Setup() {
717725
718726 /* We do the call to ares_init_option for caller. */
719727 const int optmask =
720- ARES_OPT_FLAGS | ARES_OPT_TIMEOUTMS | ARES_OPT_SOCK_STATE_CB;
728+ ARES_OPT_FLAGS | ARES_OPT_TIMEOUTMS |
729+ ARES_OPT_SOCK_STATE_CB | ARES_OPT_TRIES;
721730 r = ares_init_options (&channel_, &options, optmask);
722731
723732 if (r != ARES_SUCCESS) {
0 commit comments