Kieran Mansley wrote:
On 1 May 2012, at 21:10, Bill Auerbach wrote:
Is it acceptable or incorrect to call tcp_recved from the receive callback even
if the pbuf isn’t freed? I am buffering pbufs in the callback until I have
enough to process what has come in. This buffering could be in the hundreds.
There’s no memory limit – I have 6000 pbufs preallocated.
I think it is best to wait until you're returning the pbuf to the stack.
tcp_recved() will indicate to the other end that it can now send more data by
increasing the window size. If you're holding all the pbufs lwIP might be
forced to drop packets when they arrive. If you wait until you free the pbufs
then the window size will more accurately reflect the amount of buffering
available.
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).
But as long as you impose an outer limit on the number of pbufs being
buffered like that (on all connections, globally!), this should not have
a negative impact on performance or what soever.
Simon
_______________________________________________
lwip-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/lwip-users