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 2022/07/29 15:51:12 UTC
[incubator-nuttx] branch master updated: [TCP] Close RAM usage optimization
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.git
The following commit(s) were added to refs/heads/master by this push:
new 26dbdba5d8 [TCP] Close RAM usage optimization
26dbdba5d8 is described below
commit 26dbdba5d8df13f7c5294e8f581954c2a99f0d69
Author: Peter van der Perk <pe...@nxp.com>
AuthorDate: Fri Jul 29 11:45:11 2022 +0200
[TCP] Close RAM usage optimization
---
net/tcp/tcp.h | 5 -----
net/tcp/tcp_close.c | 20 +++++++++-----------
2 files changed, 9 insertions(+), 16 deletions(-)
diff --git a/net/tcp/tcp.h b/net/tcp/tcp.h
index c11550d742..dd57ed947c 100644
--- a/net/tcp/tcp.h
+++ b/net/tcp/tcp.h
@@ -304,11 +304,6 @@ struct tcp_conn_s
FAR struct devif_callback_s *connevents;
FAR struct devif_callback_s *connevents_tail;
- /* Reference to TCP close callback instance */
-
- FAR struct devif_callback_s *clscb;
- struct work_s clswork;
-
#if defined(CONFIG_NET_TCP_WRITE_BUFFERS)
/* Callback instance for TCP send() */
diff --git a/net/tcp/tcp_close.c b/net/tcp/tcp_close.c
index 4dca880ae8..50f466d430 100644
--- a/net/tcp/tcp_close.c
+++ b/net/tcp/tcp_close.c
@@ -53,8 +53,6 @@ static void tcp_close_work(FAR void *param)
net_lock();
- tcp_callback_free(conn, conn->clscb);
-
/* Stop the network monitor for all sockets */
tcp_stop_monitor(conn, TCP_CLOSE);
@@ -71,7 +69,8 @@ static uint16_t tcp_close_eventhandler(FAR struct net_driver_s *dev,
FAR void *pvconn, FAR void *pvpriv,
uint16_t flags)
{
- FAR struct tcp_conn_s *conn = pvpriv;
+ FAR struct tcp_conn_s *conn = pvconn;
+ FAR struct devif_callback_s *cb = pvpriv;
ninfo("flags: %04x\n", flags);
@@ -178,13 +177,11 @@ static uint16_t tcp_close_eventhandler(FAR struct net_driver_s *dev,
return flags;
end_wait:
- conn->clscb->flags = 0;
- conn->clscb->priv = NULL;
- conn->clscb->event = NULL;
+ tcp_callback_free(conn, cb);
/* Free network resources */
- work_queue(LPWORK, &conn->clswork, tcp_close_work, conn, 0);
+ work_queue(LPWORK, &conn->work, tcp_close_work, conn, 0);
return flags;
}
@@ -256,6 +253,7 @@ static inline void tcp_close_txnotify(FAR struct socket *psock,
static inline int tcp_close_disconnect(FAR struct socket *psock)
{
FAR struct tcp_conn_s *conn;
+ FAR struct devif_callback_s *cb;
int ret = OK;
/* Interrupts are disabled here to avoid race conditions */
@@ -308,13 +306,13 @@ static inline int tcp_close_disconnect(FAR struct socket *psock)
if ((conn->tcpstateflags == TCP_ESTABLISHED ||
conn->tcpstateflags == TCP_LAST_ACK) &&
- (conn->clscb = tcp_callback_alloc(conn)) != NULL)
+ (cb = tcp_callback_alloc(conn)) != NULL)
{
/* Set up to receive TCP data event callbacks */
- conn->clscb->flags = (TCP_NEWDATA | TCP_POLL | TCP_DISCONN_EVENTS);
- conn->clscb->event = tcp_close_eventhandler;
- conn->clscb->priv = conn;
+ cb->flags = (TCP_NEWDATA | TCP_POLL | TCP_DISCONN_EVENTS);
+ cb->event = tcp_close_eventhandler;
+ cb->priv = cb; /* reference for event handler to free cb */
/* Notify the device driver of the availability of TX data */