netutils/usrsock_rpmsg: Switch the nonblocking mode by psock_ioctl instead

since it's more simpler than psock_ioctl

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-03-04 16:44:18 +08:00 committed by Petro Karashchenko
parent 02a095bb76
commit f31cc67da8

View File

@ -25,12 +25,12 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h>
#include <poll.h> #include <poll.h>
#include <pthread.h> #include <pthread.h>
#include <string.h> #include <string.h>
#include <sys/eventfd.h> #include <sys/eventfd.h>
#include <sys/ioctl.h>
#include <nuttx/net/dns.h> #include <nuttx/net/dns.h>
#include <nuttx/net/net.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); pthread_mutex_lock(&priv->mutex);
if (priv->socks[i].s_conn == NULL) if (priv->socks[i].s_conn == NULL)
{ {
ret = psock_socket(req->domain, req->type, req->protocol, ret = psock_socket(req->domain, req->type | SOCK_NONBLOCK,
&priv->socks[i]); req->protocol, &priv->socks[i]);
pthread_mutex_unlock(&priv->mutex); pthread_mutex_unlock(&priv->mutex);
if (ret >= 0) if (ret >= 0)
{ {
psock_fcntl(&priv->socks[i], F_SETFL,
psock_fcntl(&priv->socks[i], F_GETFL) | O_NONBLOCK);
priv->epts[i] = ept; priv->epts[i] = ept;
ret = i; /* Return index as the usockid */ 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); pthread_mutex_unlock(&priv->mutex);
if (ret >= 0) if (ret >= 0)
{ {
psock_fcntl(&priv->socks[i], F_SETFL, int nonblock = 1;
psock_fcntl(&priv->socks[i], F_GETFL) | O_NONBLOCK);
psock_ioctl(&priv->socks[i], FIONBIO, &nonblock);
priv->epts[i] = ept; priv->epts[i] = ept;
/* Append index as usockid to the payload */ /* Append index as usockid to the payload */