File descriptors leak (not released properly) #172

Open
fswane opened this Issue Nov 6, 2017 · 2 comments

Comments

Projects
None yet
2 participants

fswane commented Nov 6, 2017

Summary:
It seems that not all sockets are released/closed properly when an input source connects and then disconnect. The open socket count for the process "voctocore" increases by 2 after every connect/disconnect cycle.

Problem description:
What I am experiencing is that when an input Source connect and then disconnects repeatedly, over time the number of open file descriptors/sockets for the Voctocore process increases. It seems the old socket allocated by a Source is not properly released when the Source disconnects.

Normally this is not a big problem, but after many disconnects and reconnects of my Sources the process runs out of its maximum allowed open sockets as determined by the operating system. Voctocore then stops to work and although the process doesn't die it is as good as dead. A restart of the process gets it going again.

My setup:

  • Ubuntu 16.04 desktop, with kernel 4.4.0-96-generic.

  • Voctocore: latest git cloned on 6 November 2017.

  • I connect and disconnect a Source to Voctocore on port 10000. (The Source is an ffmpeg instance streaming a local media file to "-f matroska tcp://localhost:10000".)

  • I check the number of open file descriptors using: 'ls /proc/3351/fd | wc -l' where 3351 is the process ID of Voctocore.

  • The number of open file descriptors increase after every connect and disconnect (it increases by 2).

  • When the Source connects, the number of file descriptors increases by 5. When it disconnects it decreases by 3. The result is a "leak" of 2 file descriptors for every connect/disconnect cycle.

  • Using 'ls -lrth /proc/3351/fd' it seems the two leaked file descriptors are sockets, since the output for these two are:

    lrwx------ 1 ubuntu ubuntu 64 Sep 28 09:59 72 -> socket:[16637009]
    lrwx------ 1 ubuntu ubuntu 64 Sep 28 09:59 71 -> socket:[16637008]

  • Using 'lsof -a -p 3351' and grepping for 16637009 and 16637008 I see both are of type "STREAM.

Am I doing something wrong which cause this leak? Is this a known issue? Any suggestions?

Collaborator

CarlFK commented Nov 29, 2017

I see it too with debian version: 1.0~RC1+git4-1

juser@cnt6:~$ pgrep voctocore 
1697
juser@cnt6:~$ ls -lrth /proc/1697/fd|wc -l
56
juser@cnt6:~$ voctomix-ingest --port 10001 >/dev/null 
wait 5 sec, kill it  ^C
juser@cnt6:~ls -lrth /proc/1697/fd|wc -ll 
58
Collaborator

CarlFK commented Nov 29, 2017

I used the following to eat up sockets:

while : 
do

gst-launch-1.0 videotestsrc  is_live=True name=videosrc \
	! identity error-after=3 \
	! video/x-raw,format=I420,width=1280,height=720,framerate=25/1,pixel-aspect-ratio=1/1 \
	! mux. audiotestsrc name=audiosrc freq=330 \
	! audio/x-raw,format=S16LE,channels=2,layout=interleaved,rate=48000 \
	! mux. matroskamux name=mux \
	! tcpclientsink host=127.0.0.1 port=10001 

done

juser@cnt6:/temp$ ulimit -n
1024
juser@cnt6:
/temp$ ls -lrth /proc/1697/fd|wc -l
1025

juser@cnt6:~/temp$ telnet localhost 9999
Trying ::1...
Connected to localhost.
Escape character is '^]'.
quit

nothing.

ps I was getting bit by this when a client was trying to feed a non existent loop for the stream blanker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment