[TCP] Close RAM usage optimization
This commit is contained in:
parent
e887a4a5b7
commit
26dbdba5d8
|
@ -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() */
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
Loading…
Reference in New Issue