Skip to content

Commit 9e1d79d

Browse files
tomerdbzgalnoam
authored andcommitted
issue: 4680622 Fix pktinfo test EINTR failures
The pktinfo.check_recvmsg_returns_expected_pktinfo test was failing sporadically with errno=4 (EINTR) when SIGCHLD from the child process exit interrupted the recvmsg() syscall before it could read the buffered packet data. Add standard EINTR retry loop to handle signal interruption during recvmsg(), allowing the syscall to complete successfully even when interrupted by signals. Fixes sporadic CI failures: Expected: (recvmsg(fd, &msg, 0)) > (0), actual: -1 vs 0 Failed to receive the msg Signed-off-by: Tomer Cabouly <[email protected]>
1 parent 1691622 commit 9e1d79d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tests/gtest/udp/udp_bind.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,11 @@ TEST_F(pktinfo, check_recvmsg_returns_expected_pktinfo)
529529
&client_addr.addr, sizeof(client_addr.addr), &vec, 1U, cbuf, sizeof(cbuf), 0
530530
};
531531

532-
ASSERT_GT(recvmsg(fd, &msg, 0), 0) << "Failed to receive the msg";
532+
ssize_t ret;
533+
do {
534+
ret = recvmsg(fd, &msg, 0);
535+
} while (ret < 0 && errno == EINTR);
536+
ASSERT_GT(ret, 0) << "Failed to receive the msg, errno=" << errno;
533537

534538
struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msg);
535539

0 commit comments

Comments
 (0)