< Previous by Date Date Index Next by Date >
  Thread Index Next in Thread >

[reSIProcate] Questions about AresDns::internalInit() method


Hi all,

I was looking at the file rutil/dns/AresDns.cxx, in particular at AresDns::checkDnsChange() and AresDns::internalInit() methods, and I noticed some things that I don’t understand.

 

Method internalInit() is used in init() and checkDnsChange(), but with different parameters. For example, in init() method for timeout and tries variables are used the values that have been set using DnsStub::setDnsTimeoutAndTries(), but in checkDnsChange() method it is used the default value (0) and in internalInit() method mChannel data member is changed instead of (I suppose) the local variable *channel (see lines 374-382).

      if (timeout > 0)

      {

         mChannel->timeout = timeout;

      }

 

      if (tries > 0)

      {

         mChannel->tries = tries;

      }

I suppose it should be:

      if (timeout > 0)

      {

         (*channel)->timeout = timeout;

      }

 

      if (tries > 0)

      {

         (*channel)->tries = tries;

      }

 

Moreover I have some doubts about the following lines of code:

#ifndef USE_CARES

      if ( mPollGrp )

      {

         // expand vector to hold {nservers} and init to NULL

         mPollItems.insert( mPollItems.end(), (*channel)->nservers, (AresDnsPollItem*)0);

         // tell ares to let us know when things change

         ares_process_set_poll_cb(mChannel, AresDnsPollItem::socket_poll_cb, this);

      }

#endif

 

In a similar way as exposed before, I don’t undertand why *channel is used to change mChannel since if internalInit() is called inside checkDnsChange() then *channel is not equal to mChannel as it happens when internalInit() is called inside init().

I think that if internalInit() is used by checkDnsChange() the previous code could (or should) not be called.

 

What is your opinions about my considerations?

 

Thank you and kind regards,

Dario.