-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unix: switch uv_sleep() to nanosleep() #2552
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a question
14ca743
to
e2167d3
Compare
On zOS, the CI is failing. I reran the CI a few times, but am still seeing the same failures:
|
I'm a bit confused. I found this article, which states:
Does that mean cc: @libuv/zos |
@libuv/zos For context, there might be a bug in libuv-on-zos's nanosleep() emulation here: libuv/src/unix/os390-syscalls.c Lines 346 to 374 in 5500253
Notably, this PR starts using the rem out parameter, which was unused before.
|
According to the documentation that @cjihrig linked to cc @ccw-1 and @zsw007 since there have been changes to this function that haven't been upstreamed here. |
Before this commit, uv_sleep() made two library calls: sleep() to sleep for the requested number of seconds, and then an usleep() call to sleep for the remaining milliseconds. Make a single nanosleep() call instead. Receiving a signal will wake up prematurely from sleep() but then re-enter sleep mode again in usleep(), which seems undesirable.
Reception of a signal makes nanosleep() return prematurely. Restart the system call when that happens.
* Remove an assert() that wasn't actually being tested because the CI builds libuv with `-DNDEBUG` on that platform. * Fix the emulation to update `errno` correctly. * Fix the emulation to update the `rem` out parameter correctly.
It looks like libuv is built with The nanosleep() emulation looks buggy to me after reading the docs on BPX1CTW/BPX4CTW. I've pushed a commit that hopefully fixes it, PTAL. CI: https://ci.nodejs.org/job/libuv-test-commit/1650/ - edit: still failing... |
Looks like it still failed... reading the failing tests ( libuv/src/unix/os390-syscalls.c Line 358 in 5500253
should be events = CW_CONDVAR | CW_INTRPT; based on the documentation:
|
Worth a try, thanks! New CI: https://ci.nodejs.org/job/libuv-test-commit/1652/ edit: of course it fails to build due to a |
Looks like we'll need to define #define CW_INTRPT 1 just before libuv/src/unix/os390-syscalls.c Line 31 in 5500253
Edit: found a source for what the values should be: https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.4.0/com.ibm.zos.v2r4.bpxb100/ycw.htm |
Done, thanks! New CI: https://ci.nodejs.org/job/libuv-test-commit/1653/ - edit: green! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
z/OS changes LGTM.
Before this commit, uv_sleep() made two library calls: sleep() to sleep for the requested number of seconds, and then an usleep() call to sleep for the remaining milliseconds. Make a single nanosleep() call instead. Receiving a signal will wake up prematurely from sleep() but then re-enter sleep mode again in usleep(), which seems undesirable. PR-URL: #2552 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reception of a signal makes nanosleep() return prematurely. Restart the system call when that happens. PR-URL: #2552 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
* Remove an assert() that wasn't actually being tested because the CI builds libuv with `-DNDEBUG` on that platform. * Fix the emulation to update `errno` correctly. * Fix the emulation to update the `rem` out parameter correctly. PR-URL: #2552 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Landed in 5500253...635e0ce. Thanks! |
Before this commit, uv_sleep() made two library calls: sleep() to sleep
for the requested number of seconds, and then an usleep() call to sleep
for the remaining milliseconds. Make a single nanosleep() call instead.
Receiving a signal will wake up prematurely from sleep() but then
re-enter sleep mode again in usleep(), which seems undesirable.
CI: https://ci.nodejs.org/job/libuv-test-commit/1634/CI: https://ci.nodejs.org/job/libuv-test-commit/1636/CI: https://ci.nodejs.org/job/libuv-test-commit/1650/CI: https://ci.nodejs.org/job/libuv-test-commit/1652/CI: https://ci.nodejs.org/job/libuv-test-commit/1653/