From 63cd44e5e16e26d916a24139f12b23194c3f372c Mon Sep 17 00:00:00 2001 From: chao an Date: Wed, 31 Aug 2022 22:22:21 +0800 Subject: [PATCH] net/usrsock: forward FIONBIO to socket level fix usrsock nonblock connect test break: apps/examples/usrsocktest/usrsocktest_noblock_connect.c: ... 157 TEST(no_block_connect, delayed_connect) 158 { ... 190 ret = fcntl(sd, F_SETFL, flags | O_NONBLOCK); ... 204 ret = connect(sd, (FAR const struct sockaddr *)&addr, sizeof(addr)); 205 TEST_ASSERT_EQUAL(-1, ret); 206 TEST_ASSERT_EQUAL(EINPROGRESS, errno); should goahead to socket level: nuttx/net/netdev/netdev_ioctl.c: ... 1755 int psock_vioctl(FAR struct socket *psock, int cmd, va_list ap) 1756 { ... 1771 ret = netdev_ioctl(psock, cmd, arg); ... 1775 if (ret == -ENOTTY) 1776 { 1777 ret = netdev_file_ioctl(psock, cmd, arg); 1778 } ... Signed-off-by: chao an --- net/usrsock/usrsock_ioctl.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/net/usrsock/usrsock_ioctl.c b/net/usrsock/usrsock_ioctl.c index 66bf83242e..91b252aaad 100644 --- a/net/usrsock/usrsock_ioctl.c +++ b/net/usrsock/usrsock_ioctl.c @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -173,6 +174,15 @@ int usrsock_ioctl(FAR struct socket *psock, int cmd, FAR void *arg, int ret; + /* Bypass FIONBIO to socket level, + * since the usrsock server always put the socket in nonblocking mode. + */ + + if (cmd == FIONBIO) + { + return -ENOTTY; + } + net_lock(); if (conn->state == USRSOCK_CONN_STATE_UNINITIALIZED ||