mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-29 13:28:27 +00:00
socket-tcp-skip-in-flight: Don't fail on EAGAIN
The server socket is marked as nonblocking, and if the client doesn't connect, accept() will fail and set errno to EAGAIN (or EWOULDBLOCK). Instead, use poll to wait for POLLIN event on the file descriptor. Suggested-by: Andrei Vagin <avagin@gmail.com> Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
This commit is contained in:
parent
681c05392d
commit
635db4895a
@ -1,3 +1,4 @@
|
||||
#include <poll.h>
|
||||
#include "zdtmtst.h"
|
||||
|
||||
#ifdef ZDTM_IPV4V6
|
||||
@ -26,9 +27,11 @@ const char *test_author = "Radostin Stoyanov <rstoyanov1@gmail.com>";
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct pollfd poll_set[1];
|
||||
int port = 9990;
|
||||
int fd_s, fd_c, fd;
|
||||
int flags;
|
||||
int ret;
|
||||
|
||||
test_init(argc, argv);
|
||||
|
||||
@ -64,12 +67,20 @@ int main(int argc, char **argv)
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(poll_set, '\0', sizeof(poll_set));
|
||||
poll_set[0].fd = fd_s;
|
||||
poll_set[0].events = POLLIN;
|
||||
ret = poll(poll_set, 1, -1);
|
||||
if (ret < 0) {
|
||||
pr_perror("poll() failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
fd = tcp_accept_server(fd_s);
|
||||
if (fd < 0) {
|
||||
fail("Unable to accept a new connection");
|
||||
return 1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
close(fd_c);
|
||||
|
Loading…
x
Reference in New Issue
Block a user