diff mbox series

[RFC,02/14] selftests: make sockets non-blocking for default poll mode

Message ID 20191114173225.21199-3-fw@strlen.de
State Superseded, archived
Headers show
Series [RFC] mptcp: wmem accounting and nonblocking io support | expand

Commit Message

Florian Westphal Nov. 14, 2019, 5:32 p.m. UTC
This change makes tests fail because mptcp_poll may signal
POLLIN when no data is there and POLLOUT when it should not.

Rest of series addresses this and makes selftest work again.

Signed-off-by: Florian Westphal <fw@strlen.de>
---
 tools/testing/selftests/net/mptcp/mptcp_connect.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/testing/selftests/net/mptcp/mptcp_connect.c
index ea8e08b1f481..ab52468a4b51 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c
@@ -279,6 +279,15 @@  static ssize_t do_rnd_read(const int fd, char *buf, const size_t len)
 	return read(fd, buf, cap);
 }
 
+static void set_nonblock(int fd)
+{
+        int flags = fcntl(fd, F_GETFL);
+        if (flags == -1)
+                return;
+
+        fcntl(fd, F_SETFL, flags | O_NONBLOCK);
+}
+
 static int copyfd_io_poll(int infd, int peerfd, int outfd)
 {
 	struct pollfd fds = {
@@ -288,6 +297,8 @@  static int copyfd_io_poll(int infd, int peerfd, int outfd)
 	unsigned int woff = 0, wlen = 0;
 	char wbuf[8192];
 
+	set_nonblock(peerfd);
+
 	for (;;) {
 		char rbuf[8192];
 		ssize_t len;