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

TS-4531: Clarify time unit confusion in HostDB sync interval. #704

Merged
merged 1 commit into from Jun 16, 2016

Conversation

jpeach
Copy link
Contributor

@jpeach jpeach commented Jun 13, 2016

Commit d48b76e tried to fix some of the time unit conversions in
HostBD, but didn't notice that RefCountedHostsFileMap::next_sync_time
was getting initialized to a nanosecond timestamp + an interval in
seconds.

This clarifies most of the timestamps uses in hosts file update
checking, which are all in Unix epoch seconds. We remove the
HOST_DB_TIMEOUT_INTERVAL definition since that interval is not
really a changeable (all the code assumes it is 1 sec).

@atsci
Copy link

atsci commented Jun 13, 2016

Linux build failed! See https://ci.trafficserver.apache.org/job/Github-Linux/124/ for details.

Commit d48b76e tried to fix some of the time unit conversions in
HostBD, but didn't notice that RefCountedHostsFileMap::next_sync_time
was getting initialized to a nanosecond timestamp + an interval in
seconds.

This clarifies most of the timestamps uses in hosts file update
checking, which are all in Unix epoch seconds. We remove the
HOST_DB_TIMEOUT_INTERVAL definition since that interval is not
really a changeable (all the code assumes it is 1 sec).
@atsci
Copy link

atsci commented Jun 13, 2016

FreeBSD build successful! See https://ci.trafficserver.apache.org/job/Github-FreeBSD/227/ for details.

@jpeach
Copy link
Contributor Author

jpeach commented Jun 13, 2016

Ping @jacksontj @SolidWallOfCode

@atsci
Copy link

atsci commented Jun 13, 2016

Linux build successful! See https://ci.trafficserver.apache.org/job/Github-Linux/125/ for details.

@atsci
Copy link

atsci commented Jun 13, 2016

FreeBSD build successful! See https://ci.trafficserver.apache.org/job/Github-FreeBSD/228/ for details.

@zwoop zwoop added the HostDB label Jun 14, 2016
@zwoop zwoop added this to the 7.0.0 milestone Jun 14, 2016
@SolidWallOfCode
Copy link
Member

I looked at the code and I am not of the opinion the code assumes HOST_DB_TIMEOUT_INTERVAL is one second. For instance, in HostDBContinuation::backgroundEvent it is explicitly scaled by HRTIME_SECOND which is the opposite of assuming it is the specific value one second.

++hostdb_current_interval;
// No nothing if hosts file checking is not enabled.
if (hostdb_hostfile_check_interval == 0) {
return EVENT_CONT;
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be EVENT_DONE? Because it's done, there is no continuing operation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The previous logic was to return EVENT_CONT. The background event is written to trigger every second but we only check the actual changes after the check interval. I assumed that it was done this way so that you can update the check interval without having to wait for it to expire.

@jpeach
Copy link
Contributor Author

jpeach commented Jun 14, 2016

I looked at the code and I am not of the opinion the code assumes HOST_DB_TIMEOUT_INTERVAL is > one second. For instance, in HostDBContinuation::backgroundEvent it is explicitly scaled by
HRTIME_SECOND which is the opposite of assuming it is the specific value one second.

HOST_DB_TIMEOUT_INTERVAL is in hrtime units, but the code only works if it is 1 sec. For example, the mtime of the file is used equivalently to the intervals, which can only work if the interval is 1sec, which can only happen if HOST_DB_TIMEOUT_INTERVAL is 1sec.

@SolidWallOfCode
Copy link
Member

Right, the interval is presumed to be seconds, which is why HOST_DB_TIMEOUT_INTERVAL is scaled by HRTIME_SECOND when updating the interval.

@SolidWallOfCode
Copy link
Member

Overall it seems fine to get rid of it.

@jpeach
Copy link
Contributor Author

jpeach commented Jun 14, 2016

Oh, I see. I thought that HOST_DB_TIMEOUT_INTERVAL was intended to be an arbitrary hrtime value.

@jpeach
Copy link
Contributor Author

jpeach commented Jun 15, 2016

@AMC Sounds like you are OK this this? If so I'll merge tomorrow.

@jpeach jpeach merged commit 00fb9df into apache:master Jun 16, 2016
JosiahWI pushed a commit to JosiahWI/trafficserver that referenced this pull request Jul 19, 2023
Making restricted_api false by default will make ATS enforce the
permissions rather than the DAC of the socket. ATS will restrict access
to privileged users for write operations while allowing broader access
for read-only options. This default should be reasonable since that is
how 9.0 used to behave.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants