All of lore.kernel.org
 help / color / mirror / Atom feed
* [MPTCP] [RFC 02/14] selftests: make sockets non-blocking for default poll mode
@ 2019-11-14 17:32 Florian Westphal
  0 siblings, 0 replies; only message in thread
From: Florian Westphal @ 2019-11-14 17:32 UTC (permalink / raw)
  To: mptcp

[-- Attachment #1: Type: text/plain, Size: 1265 bytes --]

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(a)strlen.de>
---
 tools/testing/selftests/net/mptcp/mptcp_connect.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

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;
-- 
2.23.0

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-11-14 17:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-14 17:32 [MPTCP] [RFC 02/14] selftests: make sockets non-blocking for default poll mode Florian Westphal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.