Last active
August 29, 2015 14:13
-
-
Save fxlv/6657ba422a9e7afd18ac to your computer and use it in GitHub Desktop.
Excerpt from eglibc-2.13/resolv/res_send.c, comments added to explain logic.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* ns == current nameserver index (eg. 1,2 or 3) | |
* statp->retrans == retransmition time interval (this is defined in resolv.h) | |
* | |
* do a bitwise shift to the left to get the new timeout | |
* if ns == 0 then this does nothing | |
*/ | |
int seconds = (statp->retrans << ns); | |
if (ns > 0) | |
// divide the time that was calculated after the bitwise shift by the nameserver count | |
seconds /= statp->nscount; | |
if (seconds <= 0) | |
// seconds can't be smaller than 0, so set it to 1 in case it is smaller | |
seconds = 1; | |
bool single_request = (statp->options & RES_SNGLKUP) != 0; | |
bool single_request_reopen = (statp->options & RES_SNGLKUPREOP) != 0; | |
int save_gotsomewhere = *gotsomewhere; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment