lwip-devel
[Top][All Lists]
Advanced

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

Re: [lwip-devel] memory leak with non blocking send on lwip 1.4.1.


From: M B
Subject: Re: [lwip-devel] memory leak with non blocking send on lwip 1.4.1.
Date: Sat, 22 Jun 2013 10:45:07 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6


Hi,

We have had serious issues with do_writemore() in 1.4.1 on non-blocking sockets. I have had the intention to look deeper into it, but time never allows me to.. Our quick-fix was to revert the whole function back to 1.4.0 to get a long term reliable communication.

In our case, we are using about 10 non blocking sockets in a very low on ram system. Part of the problem was related to memory if *my* memory serves me right :).

This is probably not related to your issues, but it might be an easy test to do - just copy do_writemore() as it is from 1.4.0.

 Micael

On 06/21/13 11:33, RAc wrote:
Hi there,

sorry if this should be a dupe; I did check the Forum and to my best
knowledge this hasn't been raised before - apologies if I should have
overlooked something...

we are using the lwip socket API to communicate. This works fine except that
the lwip_write() function occassionally hangs; we could trace this scenario
to a connection being closed at the "wrong" time. Not a problem by itself; a
solid implementation will avoid blocking scenarios anyways.

It turns out that lwip_write translates to

lwip_send(s, data, size, 0);

since a valid parameter for the flags field is MSG_DONTWAIT, we replaced the
calls to write() (which is a macro wrapper for lwip_write()) with a call to

lwip_send(s, data, size, MSG_DONTWAIT);

and consequently evaluate all the returns. This works fine and doesn't cause
hangs anymore; however, there is a memory leak now. The closest I came to
debugging it is that the memory section not freed appears to be a pcb
allcated in tcp_alloc in tcp.c:

   pcb = (struct tcp_pcb *)memp_malloc(MEMP_TCP_PCB);

I've tried to further follow the scenarios where the pcb normally is
deallocated, but this goes a little bit too far into the guts of lwip for me
to pinpoint further without a lot of digging into the code.

Are there known issues with timeout sends under lwip 1.4.1.?

I also looked into the SO_SNDTIMEO socket option, but a) the declaration in
sockets.h indicates that the option is unimplemented and b) even though it
says so, it appears that there is an implementation for it but it seems to
end up in the same code path as the dontwait.

Any input is appreciated, thanks. Please do NOT argue about the thing being
unsupported or something the like without at the same time providing some
option to avoid the hang. :-) Thanks!




--
View this message in context: 
http://lwip.100.n7.nabble.com/memory-leak-with-non-blocking-send-on-lwip-1-4-1-tp21577.html
Sent from the lwip-devel mailing list archive at Nabble.com.

_______________________________________________
lwip-devel mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-devel





reply via email to

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