fix(lib): a null clock must have tv_nsec
be 0 as well
#3372
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.
Closes #3341
In a WASM environment, it seems like calling
clock_gettime
withCLOCK_MONOTONIC
gives us a really small time at first; it could be related to when the program starts, I'm not sure. The problem is our check forclock_is_null
only checks iftv_sec
is 0, and when we first setend_clock
, it is set to a value wheretv_sec
is 0, andtv_nsec
is some large number, around 0.05-0.1s in my testing. So we should also check fortv_nsec
being non-zero before assuming a clock is null/none.