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.
This refactors the internal usages of the current time.
php_time.h
to be used instead of systemtime.h
php_realtime_get
,php_realtime_spec
andphp_realtime_res
as a wrapper aroundtimespec_get[res]
,clock_get[time|res]
,gettimeofday
andtime
using the realtime clockphp_monotime_get
,php_monotime_spec
andphp_monotime_res
as a wrapper aroundtimespec_get[res]
,clock_get[time|res]
using the monotonic clocktimeval
andtimespec
php_*
timespec
for current time but keeptimeval
for timeoutsAs a result:
php_realtime_get
will not fail as it falls backtimespec_get
->clock_gettime
->gettimeofday
->time
andtime
will never failphp_realtime_get
will be available for sure because of the samelong
oftimeval.tv_sec
should be avoidedmicrotime()
/gettimeofday(true)
without BC breakuniqid
refactored a bit to not wait for the next time but increments if the current time is less or equal to the previous call. This should be faster and resolve a theoretical issue if the real time got modified in between (ntp)Even thought
gettimeofday
may not be available it wasn't checked everywhere before and compiling would have been failed already before. Availability should now be checked but as it falls back and it must have been available before I removed the conditions aroundmicrotime
,gettimeofday
anduniqid
This should fix #17856
PS: It's not fully refactored yet but a general pre-review would be welcome.