From a7dea8ddf6441ebddd83da5ced71e129a4a26e4e Mon Sep 17 00:00:00 2001 From: ligd Date: Fri, 6 Jan 2023 22:27:03 +0800 Subject: [PATCH] rpmsg_socket: shouldn't call create_device again after create_ept Signed-off-by: ligd --- 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,