rpmsg_socket: shouldn't call create_device again after create_ept

Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
ligd 2023-01-06 22:27:03 +08:00 committed by Xiang Xiao
parent d6cad21a17
commit a7dea8ddf6
1 changed files with 12 additions and 2 deletions

View File

@ -107,6 +107,7 @@ struct rpmsg_socket_conn_s
/* server listen-scoket listening: backlog > 0; /* server listen-scoket listening: backlog > 0;
* server listen-scoket closed: backlog = -1; * server listen-scoket closed: backlog = -1;
* accept scoket: backlog = -2;
* others: backlog = 0; * others: backlog = 0;
*/ */
@ -756,8 +757,9 @@ static int rpmsg_socket_accept(FAR struct socket *psock,
if (conn) if (conn)
{ {
conn->backlog = -2;
rpmsg_register_callback(conn, rpmsg_register_callback(conn,
rpmsg_socket_device_created, NULL,
rpmsg_socket_device_destroy, rpmsg_socket_device_destroy,
NULL, NULL,
NULL); NULL);
@ -1278,7 +1280,15 @@ static int rpmsg_socket_close(FAR struct socket *psock)
return 0; 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, rpmsg_unregister_callback(conn,
NULL, NULL,