You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/01/17 18:11:25 UTC

[nuttx] 03/04: rpmsg_socket: shouldn't call create_device again after create_ept

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

commit a7dea8ddf6441ebddd83da5ced71e129a4a26e4e
Author: ligd <li...@xiaomi.com>
AuthorDate: Fri Jan 6 22:27:03 2023 +0800

    rpmsg_socket: shouldn't call create_device again after create_ept
    
    Signed-off-by: ligd <li...@xiaomi.com>
---
 net/rpmsg/rpmsg_sockif.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/net/rpmsg/rpmsg_sockif.c b/net/rpmsg/rpmsg_sockif.c
index 66a274a2bf..e674795bc8 100644
--- a/net/rpmsg/rpmsg_sockif.c
+++ b/net/rpmsg/rpmsg_sockif.c
@@ -107,6 +107,7 @@ struct rpmsg_socket_conn_s
 
   /* server listen-scoket listening: backlog > 0;
    * server listen-scoket closed: backlog = -1;
+   * accept scoket: backlog = -2;
    * others: backlog = 0;
    */
 
@@ -756,8 +757,9 @@ static int rpmsg_socket_accept(FAR struct socket *psock,
 
       if (conn)
         {
+          conn->backlog = -2;
           rpmsg_register_callback(conn,
-                                  rpmsg_socket_device_created,
+                                  NULL,
                                   rpmsg_socket_device_destroy,
                                   NULL,
                                   NULL);
@@ -1278,7 +1280,15 @@ static int rpmsg_socket_close(FAR struct socket *psock)
       return 0;
     }
 
-  if (conn->backlog)
+  if (conn->backlog == -2)
+    {
+      rpmsg_unregister_callback(conn,
+                                NULL,
+                                rpmsg_socket_device_destroy,
+                                NULL,
+                                NULL);
+    }
+  else if (conn->backlog)
     {
       rpmsg_unregister_callback(conn,
                                 NULL,