lwip-devel
[Top][All Lists]
Advanced

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

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


From: RAc
Subject: [lwip-devel] memory leak with non blocking send on lwip 1.4.1.
Date: Fri, 21 Jun 2013 02:33:37 -0700 (PDT)

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.



reply via email to

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