Commit 8744bf3
issue: 4680622 Fix sporadic udp_connect fails
The mapped_ipv4_connect test was failing sporadically with recv()
returning -1 and errno=EINTR (Interrupted system call). This occurred
due to a race condition between the child process exit and the parent's
blocking recv() call.
The test forks a child process to send a UDP packet, while the parent
waits to receive it. When the child completes and exits, the kernel
delivers a SIGCHLD signal to the parent. If this signal arrives while
the parent is blocked in recv(), the system call is interrupted and
returns EINTR.
The timing of SIGCHLD delivery relative to recv() determines whether
the test passes or fails:
- SIGCHLD before recv(): packet received successfully
- SIGCHLD during recv(): recv() interrupted with EINTR
This is a classic Unix signal handling issue. The standard solution is
to retry the system call when interrupted by a signal.
Wrap recv() in a do-while loop that retries on EINTR, following the
standard Unix pattern for handling interrupted system calls. This
ensures the test completes successfully regardless of signal timing.
Signed-off-by: Tomer Cabouly <[email protected]>1 parent f7e0448 commit 8744bf3
1 file changed
+3
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
227 | 229 | | |
228 | 230 | | |
229 | 231 | | |
| |||
0 commit comments