Conversation
The previous logic throttled GMT date updates via photon::now (a monotonic-style timestamp) with a 60s interval. After a system clock jump, the cached Date header could stay stale for up to 60 seconds, causing OSS requests to be rejected (RequestTimeTooSkewed / signature mismatch) until the throttle expired. Now each sign() reads std::time() directly (a cheap vDSO call) and re-formats the GMT strings whenever the second changes. The throttle grain matches the 1-second resolution of the Date format, so it is never coarser than correctness requires, and gmtime_r/strftime still run at most once per second.
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.
Background
update_gmt_date()cached the GMTDate/x-oss-dateheader strings and only refreshed them every 60 seconds, with the interval measured byphoton::now(a CLOCK_BOOTTIME-based timestamp) while the cached values themselves came from the wall clock (std::time).This breaks in the common sandbox suspend/resume scenario: when a sandbox wakes up, the system wall clock steps forward by the whole suspend duration (not a manual adjustment). The cached headers keep the pre-sleep timestamp, and the
photon::now-based throttle does not notice the jump, so OSS requests can be signed with a stale Date for up to 60 seconds and get rejected (RequestTimeTooSkewed / signature mismatch).Change
Drop the interval-based throttling. Every sign() reads the wall clock directly (a vDSO call, ~tens of ns) and re-formats the cached strings whenever the second changes:
The 1-second refresh grain exactly matches the resolution of the date formats, so it is never coarser than correctness requires, while
gmtime_r+strftimestill run at most once per second. The now-unusedGMT_UPDATE_INTERVALconstant is removed.After this change, the first request following a clock jump is already signed with the correct post-wake time.
Files changed
ecosystem/oss.cpp— rewriteupdate_gmt_date()ecosystem/oss_constants.h— drop unusedGMT_UPDATE_INTERVALValidation