Repository navigation
Make usleep() and time_nanosleep() alertable on Windows - #24399
nicolas-grekas wants to merge 3 commits into
Conversation
4424d99 to
dffe371
Compare
arnaud-lb
left a comment
There was a problem hiding this comment.
This looks right to me, but I would like another review
| zend_hrtime_t elapsed = zend_hrtime() - start; | ||
| time_t seconds = rqtp->tv_sec - (time_t) (elapsed / ZEND_NANO_IN_SEC); | ||
| long nanoseconds = rqtp->tv_nsec - (long) (elapsed % ZEND_NANO_IN_SEC); |
There was a problem hiding this comment.
A queued APC with a 1s callback makes time_nanosleep(2, 0) report ~1s remaining although no sleep occurred. Please exclude callback time from the remainder while preserving time_sleep_until() deadline.
There was a problem hiding this comment.
Done for APCs that are already queued when the sleep starts. nanosleep() now runs them first and reports the full duration as remaining.
An APC that arrives during the sleep runs before the wait returns. I don't see a way to separate its runtime from the time slept.
time_sleep_until() now resumes against its deadline instead of using the remainder.
…time slept time_sleep_until() now resumes against its deadline. The test resolves undecorated kernel32.dll exports, so that it also works on x86.
|
Thanks for the reviews, comments addressed. |
Allow APCs to interrupt
usleep()andtime_nanosleep()on Windows, as they already can withsleep().time_nanosleep()reports the remaining duration, andtime_sleep_until()resumes waiting until its deadline.I spotted this while working on FrankenPHP and its ability to forcibly shutdown threads.