This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 9f4a15110c net: Finish FIONBIO default action if si_ioctl return OK
9f4a15110c is described below
commit 9f4a15110c6bd59fd6acd92ad497e32eca9c6a52
Author: Xiang Xiao <[email protected]>
AuthorDate: Tue Mar 7 04:22:31 2023 +0800
net: Finish FIONBIO default action if si_ioctl return OK
Continue the work: https://github.com/apache/nuttx/pull/6976
Signed-off-by: Xiang Xiao <[email protected]>
---
net/netdev/netdev_ioctl.c | 85 +++++++++++++++++------------------------------
1 file changed, 30 insertions(+), 55 deletions(-)
diff --git a/net/netdev/netdev_ioctl.c b/net/netdev/netdev_ioctl.c
index a2461522a1..9db10e28b0 100644
--- a/net/netdev/netdev_ioctl.c
+++ b/net/netdev/netdev_ioctl.c
@@ -1462,10 +1462,10 @@ static int netdev_rt_ioctl(FAR struct socket *psock,
int cmd,
#endif
/****************************************************************************
- * Name: netdev_file_ioctl
+ * Name: netdev_ioctl
*
* Description:
- * Perform file ioctl operations.
+ * Perform user private ioctl operations.
*
* Parameters:
* psock Socket structure
@@ -1478,10 +1478,20 @@ static int netdev_rt_ioctl(FAR struct socket *psock,
int cmd,
*
****************************************************************************/
-static int netdev_file_ioctl(FAR struct socket *psock, int cmd,
- unsigned long arg)
+static int netdev_ioctl(FAR struct socket *psock, int cmd,
+ unsigned long arg)
{
- int ret = OK;
+ int ret = -ENOTTY;
+
+ if (psock->s_sockif && psock->s_sockif->si_ioctl)
+ {
+ ret = psock->s_sockif->si_ioctl(psock, cmd, arg);
+ }
+
+ if (ret != OK && ret != -ENOTTY)
+ {
+ return ret;
+ }
switch (cmd)
{
@@ -1491,10 +1501,10 @@ static int netdev_file_ioctl(FAR struct socket *psock,
int cmd,
FAR int *nonblock = (FAR int *)(uintptr_t)arg;
sockcaps_t sockcaps;
- /* Non-blocking is the only configurable option. And it applies
- * only Unix domain sockets and to read operations on TCP/IP
- * and UDP/IP sockets when read-ahead is enabled.
- */
+ /* Non-blocking is the only configurable option. And it applies
+ * only Unix domain sockets and to read operations on TCP/IP
+ * and UDP/IP sockets when read-ahead is enabled.
+ */
DEBUGASSERT(psock->s_sockif != NULL &&
psock->s_sockif->si_sockcaps != NULL);
@@ -1502,14 +1512,16 @@ static int netdev_file_ioctl(FAR struct socket *psock,
int cmd,
if ((sockcaps & SOCKCAP_NONBLOCKING) != 0)
{
- if (nonblock && *nonblock)
- {
- conn->s_flags |= _SF_NONBLOCK;
- }
- else
- {
- conn->s_flags &= ~_SF_NONBLOCK;
- }
+ if (nonblock && *nonblock)
+ {
+ conn->s_flags |= _SF_NONBLOCK;
+ }
+ else
+ {
+ conn->s_flags &= ~_SF_NONBLOCK;
+ }
+
+ ret = OK;
}
else
{
@@ -1517,46 +1529,16 @@ static int netdev_file_ioctl(FAR struct socket *psock,
int cmd,
ret = -ENOSYS;
}
}
+
break;
default:
- ret = -ENOTTY;
break;
}
return ret;
}
-/****************************************************************************
- * Name: netdev_ioctl
- *
- * Description:
- * Perform user private ioctl operations.
- *
- * Parameters:
- * psock Socket structure
- * cmd The ioctl command
- * arg The argument of the ioctl cmd
- *
- * Return:
- * >=0 on success (positive non-zero values are cmd-specific)
- * Negated errno returned on failure.
- *
- ****************************************************************************/
-
-static int netdev_ioctl(FAR struct socket *psock, int cmd,
- unsigned long arg)
-{
- if (psock->s_sockif && psock->s_sockif->si_ioctl)
- {
- return psock->s_sockif->si_ioctl(psock, cmd, arg);
- }
- else
- {
- return -ENOTTY;
- }
-}
-
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -1696,13 +1678,6 @@ int psock_vioctl(FAR struct socket *psock, int cmd,
va_list ap)
ret = netdev_ioctl(psock, cmd, arg);
- /* Check for file ioctl command */
-
- if (ret == -ENOTTY)
- {
- ret = netdev_file_ioctl(psock, cmd, arg);
- }
-
/* Check for a standard network IOCTL command. */
if (ret == -ENOTTY)