[En-Nut-Discussion] TCP sockets stuck in closing state

Coleman Brumley cbrumley at polarsoft.biz
Tue May 5 04:41:28 CEST 2015

Hello. Forgive me for repeating myself (if my earlier posts actually get
through they may not as they were sent in HTML format inadvertently). 

I have a controller, using Nut/OS 4.8.7 on an Atmel AT91SAM7X256, whose web
interface relies on JavaScript and AJAX for getting data from the
controller. The JavaScript periodically requests the data and updates the

I apologize ahead of time, I cannot upgrade to the latest version for
several, complicated reasons. So, I'm hoping there is a solution to this
problem in a later version that I can back port to the version I'm using.

The problem I'm having is a slow memory leak, and I believe I've narrowed it
down to TCP sockets getting stuck, permanently, in the CLOSING state. During
my last test, I believe I've isolated this to only happening with IE, but I
cannot say to my customer "Hey, don't use IE". 

The sockets in question get into the CLOSING state and stay there until the
controller is rebooted. This is obviously, causing heap space to be tied up
and what I think is happening is that several sockets get into this stuck
state until the controller is simply out of heap space. 

To determine this, I've added code to print the socket status every 20

I've set the SNDTIMEO and RCVTIMEO options on the HTTP TCP socket to 1000
each. But, that hasn't affected this issue. I then removed all reference to
KEEPALIVE in httpd.c thinking that may be the problem, but that doesn't
seemed to have helped. 

I will let the controller run overnight and see if the sockets ever actually
close. My console output is being logged to file, so I can track down when
they actually closed and are removed...assuming they do. I've long since
closed the IE windows (over 20 minutes ago!). 

Does anyone have any guidance as to how I can fix this???

Thanks in advance,

More information about the En-Nut-Discussion mailing list