|
From: | address@hidden |
Subject: | Re: [lwip-users] tcp_recved |
Date: | Wed, 02 May 2012 23:00:47 +0200 |
User-agent: | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:11.0) Gecko/20120327 Thunderbird/11.0.1 |
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
[Prev in Thread] | Current Thread | [Next in Thread] |