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

commit 3d0a49f33e1122fc61fab8faeee797d2946bb43d
Author: chao an <anc...@xiaomi.com>
AuthorDate: Wed Aug 31 23:33:29 2022 +0800

    examples/usrsocktest: read from the closed remote should return EOF
    
    fix usrsock remote_disconnect fail:
    
    nsh> usrsocktest
    ...
    Testing group "remote_disconnect" =>
            [TEST ASSERT FAILED!]
                    In function "receive":
                    line 497: Assertion `(ssize_t)((ret)) == (ssize_t)((0))' 
failed.
                            got value: -1
                            should be: 0
            Group "remote_disconnect": [FAILED]
    ...
    
    Reference:
    
    RECV(2)
    
    NAME
           recv, recvfrom, recvmsg - receive a message from a socket
    ...
    RETURN VALUE
    ...
           When a stream socket peer has performed an orderly shutdown,
           the return value will be 0 (the traditional "end-of-file" return).
    
           Datagram sockets in various domains (e.g., the UNIX and Internet 
domains)
           permit zero-length datagrams.  When such a datagram is received, the 
return value is 0.
    
    Signed-off-by: chao an <anc...@xiaomi.com>
---
 examples/usrsocktest/usrsocktest_daemon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/usrsocktest/usrsocktest_daemon.c 
b/examples/usrsocktest/usrsocktest_daemon.c
index 849339ab1..9bdd8ccfe 100644
--- a/examples/usrsocktest/usrsocktest_daemon.c
+++ b/examples/usrsocktest/usrsocktest_daemon.c
@@ -856,7 +856,7 @@ static int recvfrom_request(int fd, FAR struct 
daemon_priv_s *priv,
 
   if (!tsock->connected)
     {
-      ret = -ENOTCONN;
+      ret = (tsock->endp) ? 0 : -ENOTCONN;
       goto prepare;
     }
 

Reply via email to