This is an automated email from the ASF dual-hosted git repository.
xiaoxiang 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 032a456c83 net/local:Add support for MSG_DONTWAIT to SOCK_STREAM
032a456c83 is described below
commit 032a456c837ecb486078e05cf280b2f01f2509e3
Author: wangyingdong <[email protected]>
AuthorDate: Tue Aug 1 19:40:28 2023 +0800
net/local:Add support for MSG_DONTWAIT to SOCK_STREAM
Signed-off-by: wangyingdong <[email protected]>
---
net/local/local_recvmsg.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/net/local/local_recvmsg.c b/net/local/local_recvmsg.c
index c8b318361d..a5e77ae5e1 100644
--- a/net/local/local_recvmsg.c
+++ b/net/local/local_recvmsg.c
@@ -224,6 +224,25 @@ psock_stream_recvfrom(FAR struct socket *psock, FAR void
*buf, size_t len,
return -ENOTCONN;
}
+ /* If it is non-blocking mode, the data in fifo is 0 and
+ * returns directly
+ */
+
+ if (flags & MSG_DONTWAIT)
+ {
+ int data_len = 0;
+ ret = file_ioctl(&conn->lc_infile, FIONREAD, &data_len);
+ if (ret < 0)
+ {
+ return ret;
+ }
+
+ if (data_len == 0)
+ {
+ return -EAGAIN;
+ }
+ }
+
/* Read the packet */
ret = psock_fifo_read(psock, buf, &readlen, true);