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/incubator-nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new f31cc67  netutils/usrsock_rpmsg: Switch the nonblocking mode by 
psock_ioctl instead
f31cc67 is described below

commit f31cc67da8626a9f3af1552f696bc3ef7c52e855
Author: Xiang Xiao <xiaoxi...@xiaomi.com>
AuthorDate: Fri Mar 4 16:44:18 2022 +0800

    netutils/usrsock_rpmsg: Switch the nonblocking mode by psock_ioctl instead
    
    since it's more simpler than psock_ioctl
    
    Signed-off-by: Xiang Xiao <xiaoxi...@xiaomi.com>
---
 netutils/usrsock_rpmsg/usrsock_rpmsg_server.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/netutils/usrsock_rpmsg/usrsock_rpmsg_server.c 
b/netutils/usrsock_rpmsg/usrsock_rpmsg_server.c
index bb322c2..fb4625a 100644
--- a/netutils/usrsock_rpmsg/usrsock_rpmsg_server.c
+++ b/netutils/usrsock_rpmsg/usrsock_rpmsg_server.c
@@ -25,12 +25,12 @@
 #include <nuttx/config.h>
 
 #include <errno.h>
-#include <fcntl.h>
 #include <poll.h>
 #include <pthread.h>
 #include <string.h>
 
 #include <sys/eventfd.h>
+#include <sys/ioctl.h>
 
 #include <nuttx/net/dns.h>
 #include <nuttx/net/net.h>
@@ -212,14 +212,11 @@ static int usrsock_rpmsg_socket_handler(struct 
rpmsg_endpoint *ept,
       pthread_mutex_lock(&priv->mutex);
       if (priv->socks[i].s_conn == NULL)
         {
-          ret = psock_socket(req->domain, req->type, req->protocol,
-                             &priv->socks[i]);
+          ret = psock_socket(req->domain, req->type | SOCK_NONBLOCK,
+                             req->protocol, &priv->socks[i]);
           pthread_mutex_unlock(&priv->mutex);
           if (ret >= 0)
             {
-              psock_fcntl(&priv->socks[i], F_SETFL,
-                psock_fcntl(&priv->socks[i], F_GETFL) | O_NONBLOCK);
-
               priv->epts[i] = ept;
               ret = i; /* Return index as the usockid */
             }
@@ -664,9 +661,9 @@ static int usrsock_rpmsg_accept_handler(struct 
rpmsg_endpoint *ept,
               pthread_mutex_unlock(&priv->mutex);
               if (ret >= 0)
                 {
-                  psock_fcntl(&priv->socks[i], F_SETFL,
-                    psock_fcntl(&priv->socks[i], F_GETFL) | O_NONBLOCK);
+                  int nonblock = 1;
 
+                  psock_ioctl(&priv->socks[i], FIONBIO, &nonblock);
                   priv->epts[i] = ept;
 
                   /* Append index as usockid to the payload */

Reply via email to