Skip to content
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

Closed

Conversation

eduard-bagdasaryan
Copy link

@eduard-bagdasaryan eduard-bagdasaryan commented Nov 18, 2024

Creating a raw pointer with 1 as an address/value raised red flags, and
it was difficult to interpret tricky peerRefreshDNS() logic correctly.

@rousskov rousskov changed the base branch from master to SQUID-770-remove-always-false-readBody-condition November 18, 2024 15:02
@rousskov rousskov changed the base branch from SQUID-770-remove-always-false-readBody-condition to master November 18, 2024 15:03
@rousskov rousskov changed the title Refactor peerRefreshDNS() to clarify its data=1 logic Refactor peerRefreshDNS() to clarify its (void*)1 logic Nov 18, 2024
src/neighbors.cc Outdated Show resolved Hide resolved
and also polished, reducing duplication.
src/neighbors.cc Outdated
/* Reconfigure the peers every hour */
eventAddIsh("peerRefreshDNS", peerRefreshDNS, nullptr, 3600.0, 1);
static void
peerScheduleDnsRefreshCheck(const double delayInSeconds)

Choose a reason for hiding this comment

The 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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved.

src/neighbors.cc Outdated

static void
peerDnsRefreshCheck(void *data)
{
if (!data && 0 == stat5minClientRequests()) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you are working on removing data from this condition and will come back to this PR after that is done.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

src/neighbors.cc Outdated

/* Reconfigure the peers every hour */

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.

Suggested change
/* Reconfigure the peers every hour */

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

Copy link

@rousskov rousskov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thank you.

@rousskov
Copy link

This work became official PR 1950.

@rousskov rousskov closed this Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants