mirror of
https://github.com/apache/nuttx.git
synced 2025-01-12 22:08:35 +08:00
tcp_recvfrom.c:malloc a new iob to handle psock_send_eventhandler when tcp_recvhandler calls tcp_newdata to clear dev->d_iob
Signed-off-by: wangchen <wangchen41@xiaomi.com>
This commit is contained in:
parent
97eef351dc
commit
8ea31668ca
1 changed files with 26 additions and 0 deletions
|
@ -393,6 +393,7 @@ static uint16_t tcp_recvhandler(FAR struct net_driver_s *dev,
|
|||
FAR void *pvpriv, uint16_t flags)
|
||||
{
|
||||
FAR struct tcp_recvfrom_s *pstate = pvpriv;
|
||||
FAR struct iob_s *iob = NULL;
|
||||
|
||||
ninfo("flags: %04x\n", flags);
|
||||
|
||||
|
@ -408,12 +409,37 @@ static uint16_t tcp_recvhandler(FAR struct net_driver_s *dev,
|
|||
|
||||
tcp_sender(dev, pstate);
|
||||
|
||||
if ((flags & TCP_ACKDATA) != 0)
|
||||
{
|
||||
iob = iob_tryalloc(false);
|
||||
if (iob == NULL)
|
||||
{
|
||||
nerr("ERROR: IOB alloc failed !\n");
|
||||
return flags;
|
||||
}
|
||||
|
||||
iob_reserve(iob, CONFIG_NET_LL_GUARDSIZE);
|
||||
int ret = iob_clone_partial(dev->d_iob, dev->d_iob->io_pktlen,
|
||||
0, iob, 0, false, false);
|
||||
if (ret < 0)
|
||||
{
|
||||
iob_free_chain(iob);
|
||||
nerr("ERROR: IOB clone failed ret=%d!\n", ret);
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
|
||||
/* Copy the data from the packet (saving any unused bytes from the
|
||||
* packet in the read-ahead buffer).
|
||||
*/
|
||||
|
||||
flags = tcp_newdata(dev, pstate, flags);
|
||||
|
||||
if (iob != NULL)
|
||||
{
|
||||
netdev_iob_replace(dev, iob);
|
||||
}
|
||||
|
||||
/* Indicate that the data has been consumed and that an ACK
|
||||
* should be sent.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue