Sockets stuck in CLOSED state...

Wojciech Puchar wojtek at wojtek.tensor.gdynia.pl
Wed Jun 18 14:47:36 UTC 2008


> ...
> tcp4      0       0  1.2.3.4.*          4.5.6.7.42149       CLOSED
> tcp4      39      0  1.2.3.4.*          4.5.6.7.54103       CLOSED
> tcp4      35      0  1.2.3.4.*          4.5.6.7.41718       CLOSED
> tcp4      38      0  1.2.3.4.*          4.5.6.7.55618       CLOSED
> tcp4      41      0  1.2.3.4.*          4.5.6.7.44230       CLOSED
> tcp4      39      0  1.2.3.4.*          4.5.6.7.49439       CLOSED
> ...
>
> These never go away; they gradually increase and increase until the 
> application starts giving errors (probably because some socket or 
> filedescriptor limit is reached). When the application is killed these 
> entries disappear.
>
> The application in question is a self written DNS server, multithreaded, and 
> running fine for years without any troubles on both BSD 5.x as well as 6.x. 
> Also 32bits as well as 64bits on 6.x.

do "stupid" thing - in your source add

#define socket TEST_SOCKET
#define connect TEST_CONNECT
#define bind TEST_BIND
#define listen TEST_LISTEN
....all other network functions you use same way here!


and write one .c program where all these TEST_* functions are defined, 
doing the same as  original PLUS logging to file.

after a while (when you see this closed/unclosed connections) stop it and 
look at logs.


i'm almost sure you will notice where is a problem.

possibly threads implementation changed...


More information about the freebsd-questions mailing list