Re: [LineControl-development] linesrv 2.1.15 leaks filedescriptors
Brought to you by:
sfuchs
|
From: S. F. <lin...@sr...> - 2005-03-04 13:28:04
|
Hi, > just today I discovered why I cannot restart linesrv while my > connection is up: > # lsof -i -P -n | grep 16007 > linesrv 18856 0 3u IPv4 46809507 TCP 192.168.0.30:16007 > (LISTEN) linesrv 18856 0 4u IPv4 46809508 UDP > 192.168.0.30:16007 linesrv 18856 0 7u IPv4 46809598 TCP > SRV:16007->ME:36731 (ESTABLISHED) dhclient 18956 0 3u IPv4 > 46809507 TCP 192.168.0.30:16007 (LISTEN) dhclient 18956 0 4u > IPv4 46809508 UDP 192.168.0.30:16007 dhclient 18956 0 7u IPv4 > 46809598 TCP SRV:16007->ME:36731 (ESTABLISHED) > > SRV == My server's ip > ME == my workstation ip > > This looks a lot like linesrv is fork()ing for running up/down > scripts without closing unneeded filedescriptors after the fork > (the child should do so though). As far as I remember... you're right. I assumed that the forked processes get terminated before the parent process gets terminated. In your case this doesn't apply. > the config for the device is: > line myline1 > interface eth1 > con_type netdev > script_up /sbin/ifup eth1 > script_dn /sbin/ifdown eth1 > line_baud_up 2000000 > line_baud_down 2000000 > allow_manually yes > script_esc /sbin/ifdown eth0 > > > Would be nice if this could be fixed in case it's not fixed already. > > linesrv-2.1/server/NEWS doesn't mention such a change between 2.1.15 > and 2.1.20 so I guess it's still there. Hmm... I just wrote a rather long paragraph about why there's a time to wait before a tcp socket can be bound to a previously used tcp port. Then I probably got the problem: You run linesrv, start the connection and the script_up doesn't terminate? Your linesrv dies (why??? shouldn't!)/gets killed and the script_up keeps running whith the tcp-16007 socket still open, right? Then you can't restart linesrv... ok, that's no surprise anymore ;). The neccessary filedescriptors can be accessed via the global variables "server" and "cltlist" (see global_vars.h). Do we need to close all (what happens with the connections to the clients if we issue a close() on their file descriptors?) or just the server socket? Closing needs to be done between fork() and exec*(). So this is probably in execute.c. I'll be glad if someone could do this for me as I've quite a few examinations in the next weeks and I regard this as a low priority bug. Due to bad design (design??) of linesrv one has to make sure not to call close() for a file descriptor which is not open yet, e.g. when exec_dont_care*() gets called before the socket is opened. Maybe we're lucky and exec_dont_care*() gets only called with an open socket... has to be checked. Greetings & thanks for the report Stefan Fuchs -- http://srf.ch/ |