Conversation
schedule_service_check() and schedule_host_check() turned check_time into a delay with time(NULL), and schedule_next_*_check() turned it back with gettimeofday(). On Linux time() reads the coarse clock, which can still show the previous second for a few milliseconds after the other has moved on, so now and then the check landed a second later than asked for. That made test_commands fail at random, about once in 40 runs; with time() forced a second behind it fails every time. Both now read the clock once and pass it down. Signed-off-by: nook24 <info@nook24.eu> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WY8mbGLNkt5eQfc57cTnZ5
nook24
marked this pull request as ready for review
September 29, 2026 14:23
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
t-tap/test_commandsfails at random, about once in 40 runs, in these four assertions:schedule_service_check()andschedule_host_check()turncheck_timeinto a delay withtime(NULL), andschedule_next_*_check()turns it back intonext_checkwithgettimeofday(). On Linuxtime()reads the coarse clock, which lags behind until the next timer tick. For a few milliseconds after every second boundary it still shows the previous second (0.29% of the time in a tight loop here). A call in that window schedules the check one second later than asked for.Both functions now read the clock once and pass it to a static helper. The public signatures in
checks_service.handchecks_host.hare unchanged. Outside the tests the effect is small: a check scheduled for a fixed time throughSCHEDULE_SVC_CHECKand friends landed a second late about 0.3% of the time.