Skip to content
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

zloop: ignore EINTR from poll if nonstop is enabled #2285

Merged
merged 2 commits into from
Apr 12, 2024

Conversation

oko256
Copy link
Contributor

@oko256 oko256 commented Apr 9, 2024

If SIGINT signal arrives while poll is blocking, regardless of attached signal handler it will cause the poll to return with errno EINTR. Currently, this causes zloop to return from the event loop. For nonstop mode to work as intended, we have to ignore EINTR in this case.

Added test cases that verify the functionality when catching an actual SIGINT signal with and without nonstop mode. Tested in Linux and Windows.

Fixes #2284

@oko256
Copy link
Contributor Author

oko256 commented Apr 9, 2024

According to CI it seems like MacOS is not happy with the way I try to test this. I'll try to figure out why.

If SIGINT signal arrives while poll is blocking, regardless of attached
signal handler it will cause the poll to return with errno EINTR.
Currently, this causes zloop to return from the event loop. For nonstop
mode to work as intended, we have to ignore EINTR in this case.

Added test cases that verify the functionality when catching an actual
SIGINT signal with and without nonstop mode. Tested in Linux and
Windows.
@oko256 oko256 force-pushed the zloop-fix-nonstop branch from d9a4787 to 3a38d94 Compare April 10, 2024 07:36
On macOS, in zsock STREAM test, when STREAM zsock was bound with
`tcp://*:*`, the respective connect to `tcp://127.0.0.1:<port>` was
unable to connect and got stuck indefinitely. Fixed by binding to
`tcp://127.0.0.1:*` instead like in other tests in zsock.
@oko256
Copy link
Contributor Author

oko256 commented Apr 10, 2024

The zloop macOS test issue was just too strict timing requirement on the test, so I relaxed those requirements a bit and now it passes nicely. The functionality itself was working just fine.

I also noticed that zsock tests have been failing apparently for some time on macOS, so I fixed that issue as well: other tests in zsock bind to 127.0.0.1:* but STREAM test was binding to *:* which didn't work on macOS and changing that fixed macOS tests as well.

@sphaero sphaero merged commit 774eb3b into zeromq:master Apr 12, 2024
9 of 11 checks passed
@sphaero
Copy link
Contributor

sphaero commented Apr 12, 2024

Thanks!

@sphaero
Copy link
Contributor

sphaero commented Jun 18, 2024

I'm not sure but it might be handy to check whether the test runs in a debugger. As it raises sigint I don't think the signal handler will be run then.

@oko256
Copy link
Contributor Author

oko256 commented Jun 22, 2024

I'm not sure but it might be handy to check whether the test runs in a debugger. As it raises sigint I don't think the signal handler will be run then.

It is true that for example in gdb by default it will break into the debugger when SIGINT is raised and one needs to set handle SIGINT nostop pass in gdb before running to pass this test.

Since this behaviour depends on the internal behaviour of poll and how it reacts to signals (errno EINTR), I don't have better idea how to test this without actually raising a SIGINT. Maybe someone has a better idea? Or of course we can just remove this test completely if it's important to pass the tests in a debugger without any extra debugger settings?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

zloop: nonstop does not work as intended (EINTR breaks loop)
2 participants