From 232ef950c60e322563d1244fffd033561bbc4762 Mon Sep 17 00:00:00 2001 From: wangjinjing1 Date: Fri, 3 Jan 2025 09:57:32 +0800 Subject: [PATCH] net/can,udp,tcp: add sem destroy for udp/tcp sndsem; standardize the usage of semphore Signed-off-by: wangjinjing1 --- net/can/can_conn.c | 4 ++++ net/can/can_sockif.c | 4 ---- net/tcp/tcp_conn.c | 4 ++++ net/udp/udp_conn.c | 4 ++++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/net/can/can_conn.c b/net/can/can_conn.c index c1605491419..a5574570594 100644 --- a/net/can/can_conn.c +++ b/net/can/can_conn.c @@ -163,6 +163,10 @@ void can_free(FAR struct can_conn_s *conn) can_sendbuffer_notify(conn); # endif /* CONFIG_NET_SEND_BUFSIZE */ +#endif + +#if CONFIG_NET_SEND_BUFSIZE > 0 + nxsem_destroy(&conn->sndsem); #endif /* Free the connection. */ diff --git a/net/can/can_sockif.c b/net/can/can_sockif.c index 71347bf83c1..aebd83985ca 100644 --- a/net/can/can_sockif.c +++ b/net/can/can_sockif.c @@ -518,10 +518,6 @@ static int can_close(FAR struct socket *psock) } #endif -#if CONFIG_NET_SEND_BUFSIZE > 0 - nxsem_destroy(&conn->sndsem); -#endif - /* Free the connection structure */ conn->crefs = 0; diff --git a/net/tcp/tcp_conn.c b/net/tcp/tcp_conn.c index 6bccd8741a8..926a97db36c 100644 --- a/net/tcp/tcp_conn.c +++ b/net/tcp/tcp_conn.c @@ -887,6 +887,10 @@ void tcp_free(FAR struct tcp_conn_s *conn) #endif +#if CONFIG_NET_SEND_BUFSIZE > 0 + nxsem_destroy(&conn->snd_sem); +#endif + #ifdef CONFIG_NET_TCPBACKLOG /* Remove any backlog attached to this connection */ diff --git a/net/udp/udp_conn.c b/net/udp/udp_conn.c index e4c253e46e7..2b1d8fc51ae 100644 --- a/net/udp/udp_conn.c +++ b/net/udp/udp_conn.c @@ -647,6 +647,10 @@ void udp_free(FAR struct udp_conn_s *conn) udp_sendbuffer_notify(conn); #endif /* CONFIG_NET_SEND_BUFSIZE */ +#endif + +#if CONFIG_NET_SEND_BUFSIZE > 0 + nxsem_destroy(&conn->sndsem); #endif /* Free the connection. */