Skip to content

Commit

Permalink
tcp_recvfrom.c:malloc a new iob to handle psock_send_eventhandler whe…
Browse files Browse the repository at this point in the history
…n tcp_recvhandler calls tcp_newdata to clear dev->d_iob

Signed-off-by: wangchen <[email protected]>
  • Loading branch information
wangchen61698 authored and xiaoxiang781216 committed Dec 28, 2024
1 parent 91a750d commit 516b732
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions net/tcp/tcp_recvfrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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.
*/
Expand Down

0 comments on commit 516b732

Please sign in to comment.