You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/03/04 16:06:05 UTC

[GitHub] [incubator-nuttx] pkarashchenko commented on a change in pull request #5681: Simplify and unify fcntl with FIOCLEX and FIONCLEX

pkarashchenko commented on a change in pull request #5681:
URL: https://github.com/apache/incubator-nuttx/pull/5681#discussion_r819698809



##########
File path: net/netdev/netdev_ioctl.c
##########
@@ -1673,13 +1673,56 @@ int psock_vioctl(FAR struct socket *psock, int cmd, va_list ap)
 
   arg = va_arg(ap, unsigned long);
 
+  /* Check for File ioctl command */
+
+  switch (cmd)
+    {
+      case FIONBIO:
+        {
+          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.
+            */
+
+          DEBUGASSERT(psock->s_sockif != NULL &&
+                      psock->s_sockif->si_sockcaps != NULL);
+          sockcaps = psock->s_sockif->si_sockcaps(psock);
+
+          if ((sockcaps & SOCKCAP_NONBLOCKING) != 0)
+            {
+               if (nonblock && *nonblock)
+                 {
+                   conn->s_flags |= _SF_NONBLOCK;
+                 }
+               else
+                 {
+                   conn->s_flags &= ~_SF_NONBLOCK;

Review comment:
       ```suggestion
                      psock->s_flags &= ~_SF_NONBLOCK;
   ```

##########
File path: net/netdev/netdev_ioctl.c
##########
@@ -1673,13 +1673,56 @@ int psock_vioctl(FAR struct socket *psock, int cmd, va_list ap)
 
   arg = va_arg(ap, unsigned long);
 
+  /* Check for File ioctl command */
+
+  switch (cmd)
+    {
+      case FIONBIO:
+        {
+          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.
+            */
+
+          DEBUGASSERT(psock->s_sockif != NULL &&
+                      psock->s_sockif->si_sockcaps != NULL);
+          sockcaps = psock->s_sockif->si_sockcaps(psock);
+
+          if ((sockcaps & SOCKCAP_NONBLOCKING) != 0)
+            {
+               if (nonblock && *nonblock)
+                 {
+                   conn->s_flags |= _SF_NONBLOCK;

Review comment:
       ```suggestion
                      psock->s_flags |= _SF_NONBLOCK;
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org