net/tcp: fix the problem of nested tx in the rxcb process

since the current txnotify is executed synchronously at the location of
the current call without switching threads, resources such as d_iob need
to be cached first.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
zhanghongyu
2025-07-14 11:10:33 +08:00
committed by Xiang Xiao
parent 2ebb08e78f
commit 9ce35caf4e
+21
View File
@@ -602,6 +602,18 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
if ((flags & TCP_NEWDATA) != 0)
{
FAR uint8_t *buf = dev->d_buf;
FAR uint8_t *appdata = dev->d_appdata;
uint16_t len = dev->d_len;
#ifdef CONFIG_NET_TCPURGDATA
FAR uint8_t *urgdata = dev->d_urgdata;
uint16_t urglen = dev->d_urglen;
#endif
FAR struct iob_s *iob = dev->d_iob;
dev->d_buf = NULL;
dev->d_iob = NULL;
/* The current receive data needs to be handled by
* following tcp_recvhandler or tcp_data_event. Notify
* driver to send the message and marked as rexmit
@@ -609,7 +621,16 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
TCP_WBNACK(wrb) = 0;
conn->timeout = true;
netdev_txnotify_dev(conn->dev);
netdev_iob_replace(dev, iob);
dev->d_buf = buf;
dev->d_appdata = appdata;
dev->d_len = len;
#ifdef CONFIG_NET_TCPURGDATA
dev->d_urgdata = urgdata;
dev->d_urglen = urglen;
#endif
return flags;
}