You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ma...@apache.org on 2020/08/06 11:52:20 UTC

[incubator-nuttx-apps] 01/05: apps/examples/usrsocktest: Add MSG_PEEK flag support

This is an automated email from the ASF dual-hosted git repository.

masayuki pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit 4bd506b7f5ce5ee041432061ae48a51b9c66ff5d
Author: SPRESENSE <41...@users.noreply.github.com>
AuthorDate: Thu Aug 6 10:50:56 2020 +0900

    apps/examples/usrsocktest: Add MSG_PEEK flag support
    
    Do not decrement the recv_avail_bytes if MSG_PEEK flag is specified.
---
 examples/usrsocktest/usrsocktest_daemon.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/examples/usrsocktest/usrsocktest_daemon.c b/examples/usrsocktest/usrsocktest_daemon.c
index f92e570..0c11a44 100644
--- a/examples/usrsocktest/usrsocktest_daemon.c
+++ b/examples/usrsocktest/usrsocktest_daemon.c
@@ -879,7 +879,12 @@ prepare:
         {
           char tmp = 'a' + i;
 
-          tsock->recv_avail_bytes--;
+          /* Check if MSG_PEEK flag is specified. */
+
+          if ((req->flags & MSG_PEEK) != MSG_PEEK)
+            {
+              tsock->recv_avail_bytes--;
+            }
 
           wlen = write(fd, &tmp, 1);
           if (wlen < 0)