Skip to content

Commit

Permalink
net/usrsock: Fix bug that socket API does not return immediately
Browse files Browse the repository at this point in the history
Fix bug that socket API does not return immediately
in non-blocking mode.
  • Loading branch information
SPRESENSE committed Mar 7, 2023
1 parent 6ba625d commit 94311f9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions net/usrsock/usrsock_ioctl.c
Expand Up @@ -32,6 +32,7 @@
#include <debug.h>

#include <sys/socket.h>
#include <sys/ioctl.h>
#include <nuttx/net/net.h>
#include <nuttx/net/usrsock.h>
#ifdef CONFIG_NETDEV_WIRELESS_IOCTL
Expand Down Expand Up @@ -174,6 +175,25 @@ int usrsock_ioctl(FAR struct socket *psock, int cmd, FAR void *arg,

int ret;

if (cmd == FIONBIO)
{
int nonblock = *((FAR int *)arg);

net_lock();

if (nonblock)
{
conn->sconn.s_flags |= _SF_NONBLOCK;
}
else
{
conn->sconn.s_flags &= ~_SF_NONBLOCK;
}

net_unlock();
return OK;
}

net_lock();

if (conn->state == USRSOCK_CONN_STATE_UNINITIALIZED ||
Expand Down

0 comments on commit 94311f9

Please sign in to comment.