lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] lwIP malloc fail


From: Navcon - Pedro Paulo Santos
Subject: Re: [lwip-users] lwIP malloc fail
Date: Wed, 14 Apr 2010 09:57:15 -0300

I undestand. So I can (and must) call a tcp_write inside recv callback, but it can't have a larger size than the internal buffers or else it will return an ERR_MEM. If I got what you said, the technique is to send what you can in recv callback to improve latency, and send the rest in the sent callback function to improve performance (better than calling it in poll callback, right?).

In my wrong code, I tried to send more data than buffers can handle inside recv callback function. I made a loop of several tcp_write() inside it and wrote nothing at the sent and poll callbacks, the result was that I got ERR_MEM error and a large part of the data wasn't send.

Thank you!

Pedro Paulo.


From: "Simon Goldschmidt" <address@hidden>
To: "Navcon - Pedro Paulo Santos" <address@hidden>; "Mailing list for lwIP users" <address@hidden>
Sent: Wednesday, April 14, 2010 2:38 AM
Subject: Re: [lwip-users] lwIP malloc fail


"Navcon - Pedro Paulo Santos" wrote:
The main mistake I did was that I tried to send all the data in the recv
callback function. As I realized, lwIP received the ACK, but didn't freed
the memory because it does so in other handler (unknown for me) different
from recv.

Which memory isn't freed? The pbufs queued for sending/retransmission should be freed *before* your receive callback is called, so this shouldn't be a problem. However, you can only send as much data as fits into the buffers when you are in the recv callback. If you have more data than that, the *sent* callback gets called if an ACK is received and you can send more data from there.

The HTTP server in CVS contrib has no problems doing it this way.

The latency can be improve for really small tranfers by sending
in the recv function, but I would not suggest this.

That's not true, there should be no problems sending from the recv callback (i.e. calling tcp_write from that callback).

Simon
--
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01


__________ Informação do ESET NOD32 Antivirus, versão da vacina 4628 (20091122) __________

A mensagem foi verificada pelo  ESET NOD32 Antivirus.

http://www.eset.com




__________ Informação do ESET NOD32 Antivirus, versão da vacina 4628 (20091122) 
__________

A mensagem foi verificada pelo  ESET NOD32 Antivirus.

http://www.eset.com







reply via email to

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