@@ -631,9 +631,14 @@ int ParseSoaReply(
631
631
}
632
632
} // anonymous namespace
633
633
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)
635
639
: AsyncWrap(env, object, PROVIDER_DNSCHANNEL),
636
- timeout_ (timeout) {
640
+ timeout_ (timeout),
641
+ tries_(tries) {
637
642
MakeWeak ();
638
643
639
644
Setup ();
@@ -647,11 +652,13 @@ void ChannelWrap::MemoryInfo(MemoryTracker* tracker) const {
647
652
648
653
void ChannelWrap::New (const FunctionCallbackInfo<Value>& args) {
649
654
CHECK (args.IsConstructCall ());
650
- CHECK_EQ (args.Length (), 1 );
655
+ CHECK_EQ (args.Length (), 2 );
651
656
CHECK (args[0 ]->IsInt32 ());
657
+ CHECK (args[1 ]->IsInt32 ());
652
658
const int timeout = args[0 ].As <Int32>()->Value ();
659
+ const int tries = args[1 ].As <Int32>()->Value ();
653
660
Environment* env = Environment::GetCurrent (args);
654
- new ChannelWrap (env, args.This (), timeout);
661
+ new ChannelWrap (env, args.This (), timeout, tries );
655
662
}
656
663
657
664
GetAddrInfoReqWrap::GetAddrInfoReqWrap (
@@ -704,6 +711,7 @@ void ChannelWrap::Setup() {
704
711
options.sock_state_cb = ares_sockstate_cb;
705
712
options.sock_state_cb_data = this ;
706
713
options.timeout = timeout_;
714
+ options.tries = tries_;
707
715
708
716
int r;
709
717
if (!library_inited_) {
@@ -717,7 +725,8 @@ void ChannelWrap::Setup() {
717
725
718
726
/* We do the call to ares_init_option for caller. */
719
727
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;
721
730
r = ares_init_options (&channel_, &options, optmask);
722
731
723
732
if (r != ARES_SUCCESS) {
0 commit comments