lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] tcp_recved


From: Simon Goldschmidt
Subject: Re: [lwip-users] tcp_recved
Date: Mon, 07 May 2012 16:23:17 +0200

"Bill Auerbach" <address@hidden> wrote:
> >As a general advisory, I'm with on that, Kieran.
> >
> >However, I think Bill's way might be correct in his very special case
> >here: calling tcp_recved from the receive callback without freeing the
> >received pbuf does not hurt the stack. The only problem might be running
> >out of pbufs (so newly arriving packets are dropped, like Kieran wrote).
> >[..]
> 
> Would this limit me to TCP_WND of received data?

No, the limit would be the availability of pbufs for RX. But you can seriously 
lock up the stack if it runs out of RX pbufs and you don't free the ones you 
buffered.

> I plan on using something like pbuf_cat to build this list keeping
> p->tot_len (the top) valid.

Keeping pbufs valid is really kind of inefficient, since *all* pbufs must have 
tot_len adjusted. I solved this by just (privately) queueing pbufs (using their 
'next' pointer) and keeping the total length in a separate variable. Then, when 
you have all data, you can either fix up the whole queue (in a single pass). 
You could even leave them as they are, if you don't pass them to any lwIP 
function expecting them to be in correct shape (pbuf_free() should handle 
that), but that's not guaranteed to work, of course.

Simon
-- 
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de



reply via email to

[Prev in Thread] Current Thread [Next in Thread]