GNOME Bugzilla – Bug 709730
GstRTSPThreadPool leaks threads
Last modified: 2014-06-22 13:55:05 UTC
Created attachment 256802 [details] [review] One ref is always kept for the thread's main loop and every call to gst_rtsp_thread_pool_get_thread () results in a new ref which is dropped from gst_thread_stop (). All reused client threads are currently leaked. I am also proposing a patch which solves the leak. One ref is always kept for the thread's main loop and every call to gst_rtsp_thread_pool_get_thread () results in a new ref which is dropped from gst_thread_stop ().
Created attachment 256806 [details] [review] Unit test for GstRTSPThreadPool Here is a unit test which reproduces the leak described in the ticket, but it also reveals another bug. If gst_rtsp_thread_stop() is called before the main loop for the thread is started it will do nothing and the main loop will eventually run. This can be solved with a mutex, flag and idle source but may be there is a nicer solution to that problem?
Created attachment 256972 [details] [review] fixing small bug in the unit test patch, free pool using g_object_unreaf instead of gst_object_unref
Review of attachment 256802 [details] [review]: ::: gst/rtsp-server/rtsp-thread-pool.c @@ +147,3 @@ * + * Stop and unref @thread. When no threads are using the mainloop, the thread + * will be stopped and the final ref to @thread will be released. This should get an corresponding annotation then if I understand it correctly... (transfer full) for the thread parameter.
Created attachment 257338 [details] [review] Fixes annotation in my previous patch - (transfer full) for the thread parameter
commit 78e5a9148e6ba8d80fd3f2e78043abd7a434ec23 Author: Ognyan Tonchev <ognyan@axis.com> Date: Wed Oct 9 15:25:10 2013 +0200 thread-pool: Fix thread leak when reusing threads https://bugzilla.gnome.org/show_bug.cgi?id=709730 commit fa7898b0a61bed689cff7f57285be561d7ab5028 Author: Ognyan Tonchev <ognyan@axis.com> Date: Wed Oct 9 15:19:12 2013 +0200 thread-pool: Add unit test for the thread pools https://bugzilla.gnome.org/show_bug.cgi?id=710228