clear CLOSE_WAIT status

Hi,

I have an application with a bug in it that keeps sockets in CLOSE_WAIT, which eventually freezes the server because the user account it runs under runs out of file handles. We have the bug fixed but can only release the fix with the next release.

Does anyone know how I can clear the sockets in CLOSE_WAIT status? This way I won't have to restart the application server every other day...

We have Red Hat Enterprise 4.

Thanks,

Reinout

You can tune many of TCP/IP related parameters from procfs/sysfs
See to document /usr/src/linux/Documentation/networking/ip-sysctl.txt
Example, for TCP there are following files
/proc/sys/net/ipv4/tcp_*
Remember changes in those file will be temperal and will not remain after system reboot. To make it parmenant you need to create "/etc/sysctl.conf" entries. Look man sysctl
Also if you can do socket shutdown then socket close in your application then it also overcome our problem

As sumitpandya indicated your code has a problem.

There have been some posts lately about this problem, try searching using the "search" button and "CLOSE_WAIT"

I know the problem is in our code and we have a fix for it but we can't role it out immediately in a production environment. Clearing the CLOSE_WAIT is just an emergency solution, and better then restarting the application servers daily.

We're planning a new release tomorrow that should fix the problem.

The fix is using a multithreaded connection pool instead of openening a new connection per request which in case of a probable memory leak causes the socket to stay occupied while being in CLOSE_WAIT.