Skip to content

Retry pselect on EINTR - #344

Merged
stapelberg merged 1 commit into
google:mainfrom
nickgarlis:retry-on-eintr
Nov 18, 2025
Merged

stapelberg merged 1 commit into
google:mainfrom
nickgarlis:retry-on-eintr

Conversation

@nickgarlis

Copy link
Copy Markdown
Contributor

The Go runtime may send signals to pause goroutines and these signals can interrupt pselect6. When this happens, the syscall returns EINTR. This change handles that case by retrying pselect6 on EINTR. The same approach is used by the mdlayher/socket library for sendmsg/recvmsg operations:
https://github.com/mdlayher/socket/blob/8e6558649a7bd11ca1bd2b82c45fc96dee4dc11d/conn.go#L871.

Should fix the bug spotted on #339. I tested by doing something like this:

until sudo ./nftables.test -test.v -run_system_tests -test.run ^TestRuleHandle$ 2>&1 | tee -a /tmp/output | grep -q FAIL; do :; done

and simultaneously using tail -f, looking for keywords on the file. It seems that very rarely ( maybe 5% of time time ) the exact same test would fail because of EINTR.

The Go runtime may send signals to pause goroutines and these signals
can interrupt pselect6. When this happens, the syscall returns EINTR.
This change handles that case by retrying pselect6 on EINTR. The same
approach is used by the mdlayher/socket library for sendmsg/recvmsg
operations:
https://github.com/mdlayher/socket/blob/8e6558649a7bd11ca1bd2b82c45fc96dee4dc11d/conn.go#L871.
@stapelberg
stapelberg merged commit 77c5b01 into google:main Nov 18, 2025
2 checks passed
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.

2 participants