-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor peerRefreshDNS() to clarify its (void*)1 logic #274
Changes from 2 commits
19ed0dd
5418183
b0fd93a
cc2457e
0a45268
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,8 @@ static void neighborAlive(CachePeer *, const MemObject *, const icp_common_t *); | |
static void neighborAliveHtcp(CachePeer *, const MemObject *, const HtcpReplyData *); | ||
#endif | ||
static void neighborCountIgnored(CachePeer *); | ||
static void peerRefreshDNS(void *); | ||
static void peerScheduleDnsRefreshCheck(double); | ||
static void peerDnsRefreshStart(); | ||
static IPH peerDNSConfigure; | ||
static void peerProbeConnect(CachePeer *, const bool reprobeIfBusy = false); | ||
static CNCB peerProbeConnectDone; | ||
|
@@ -533,7 +534,7 @@ neighbors_init(void) | |
} | ||
} | ||
|
||
peerRefreshDNS((void *) 1); | ||
peerDnsRefreshStart(); | ||
|
||
sep = getservbyname("echo", "udp"); | ||
echo_port = sep ? ntohs((unsigned short) sep->s_port) : 7; | ||
|
@@ -1148,22 +1149,33 @@ peerDNSConfigure(const ipcache_addrs *ia, const Dns::LookupDetails &, void *data | |
} | ||
|
||
static void | ||
peerRefreshDNS(void *data) | ||
peerDnsRefreshStart() | ||
{ | ||
if (eventFind(peerRefreshDNS, nullptr)) | ||
eventDelete(peerRefreshDNS, nullptr); | ||
for (const auto &p: CurrentCachePeers()) | ||
ipcache_nbgethostbyname(p->host, peerDNSConfigure, p.get()); | ||
|
||
/* Reconfigure the peers every hour */ | ||
peerScheduleDnsRefreshCheck(3600.0); | ||
} | ||
|
||
static void | ||
peerDnsRefreshCheck(void *data) | ||
{ | ||
if (!data && 0 == stat5minClientRequests()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume you are working on removing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
/* no recent client traffic, wait a bit */ | ||
eventAddIsh("peerRefreshDNS", peerRefreshDNS, nullptr, 180.0, 1); | ||
peerScheduleDnsRefreshCheck(180.0); | ||
return; | ||
} | ||
|
||
for (const auto &p: CurrentCachePeers()) | ||
ipcache_nbgethostbyname(p->host, peerDNSConfigure, p.get()); | ||
peerDnsRefreshStart(); | ||
} | ||
|
||
/* Reconfigure the peers every hour */ | ||
eventAddIsh("peerRefreshDNS", peerRefreshDNS, nullptr, 3600.0, 1); | ||
static void | ||
peerScheduleDnsRefreshCheck(const double delayInSeconds) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please try to move this up, where the old eventFind() was, to simplify the diff. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved. |
||
{ | ||
if (eventFind(peerDnsRefreshCheck, nullptr)) | ||
eventDelete(peerDnsRefreshCheck, nullptr); | ||
eventAddIsh("peerDnsRefreshCheck", peerDnsRefreshCheck, nullptr, delayInSeconds, 1); | ||
} | ||
|
||
/// whether new TCP probes are currently banned | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's drop this misleading comment. This self-documented code is not reconfiguring cache_peers. The only problem here is that 3600.0 constant lacks "this is an hour" annotation, but that will be fixed when we migrate this code to std::chrono.
I do not think we should migrate in this PR, but we will migrate if others insist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.