rtspsrc: socket descriptors not freed on unrefing parent pipeline
Submitted by Yuuki
Link to original bug (#750651)
Description
If connection to RTSP source can't be established, I do unref pipeline and create new one. Each of this recreations of pipeline spawns new socket descriptors in /proc/<pid>
/fd and total number of them is grows. After hundred or so such cycles my code crashes.
If I run my code under valgrind, it is not crashed, but valgrind says instead:
==26342== Warning: invalid file descriptor 1031 in syscall socketcall.socketpair()
==26342== Warning: invalid file descriptor 1031 in syscall open()
==26342== Warning: invalid file descriptor 1031 in syscall open()
==26342== Warning: invalid file descriptor 1032 in syscall write()
Stopping app gives:
==26342== 37,382 (8,000 direct, 29,382 indirect) bytes in 500 blocks are definitely lost in loss record 3,638 of 3,666
==26342== at 0x4C2BBA0: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==26342== by 0x5198799: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4400.0)
==26342== by 0x51AF6AF: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4400.0)
==26342== by 0x517E44C: g_error_new_literal (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4400.0)
==26342== by 0x517E71D: g_set_error_literal (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4400.0)
==26342== by 0x8081F67: g_cancellable_set_error_if_cancelled (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.4400.0)
==26342== by 0x80BF73A: g_socket_condition_timed_wait (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.4400.0)
==26342== by 0x80C2361: g_socket_connect (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.4400.0)
==26342== by 0x80C51F5: g_socket_client_connect (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.4400.0)
==26342== by 0x80C5799: g_socket_client_connect_to_uri (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.4400.0)
==26342== by 0x85F2B5B: gst_rtsp_connection_connect (in /usr/lib/x86_64-linux-gnu/libgstrtsp-1.0.so.0.405.0)
==26342== by 0x7E2B8C1: gst_rtsp_conninfo_connect (in /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstrtsp.so)
Version: 1.4.5