mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
thread-pool: Unref reused threads in gst_rtsp_thread_stop()
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=723519
This commit is contained in:
parent
71c45fce5a
commit
274d4b017f
2 changed files with 12 additions and 3 deletions
|
@ -133,12 +133,17 @@ gboolean
|
|||
gst_rtsp_thread_reuse (GstRTSPThread * thread)
|
||||
{
|
||||
GstRTSPThreadImpl *impl = (GstRTSPThreadImpl *) thread;
|
||||
gboolean res;
|
||||
|
||||
g_return_val_if_fail (GST_IS_RTSP_THREAD (thread), FALSE);
|
||||
|
||||
GST_DEBUG ("reuse thread %p", thread);
|
||||
|
||||
return g_atomic_int_add (&impl->reused, 1) > 0;
|
||||
res = g_atomic_int_add (&impl->reused, 1) > 0;
|
||||
if (res)
|
||||
gst_rtsp_thread_ref (thread);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -174,7 +179,8 @@ gst_rtsp_thread_stop (GstRTSPThread * thread)
|
|||
thread, (GDestroyNotify) gst_rtsp_thread_unref);
|
||||
g_source_attach (source, thread->context);
|
||||
g_source_unref (source);
|
||||
}
|
||||
} else
|
||||
gst_rtsp_thread_unref (thread);
|
||||
}
|
||||
|
||||
#define GST_RTSP_THREAD_POOL_GET_PRIVATE(obj) \
|
||||
|
@ -458,7 +464,6 @@ default_get_thread (GstRTSPThreadPool * pool,
|
|||
* stops. */
|
||||
goto retry;
|
||||
}
|
||||
gst_rtsp_thread_ref (thread);
|
||||
} else {
|
||||
/* make more threads */
|
||||
GST_DEBUG_OBJECT (pool, "make new client thread");
|
||||
|
|
|
@ -34,6 +34,8 @@ GST_START_TEST (test_pool_get_thread)
|
|||
thread = gst_rtsp_thread_pool_get_thread (pool, GST_RTSP_THREAD_TYPE_CLIENT,
|
||||
NULL);
|
||||
fail_unless (thread != NULL);
|
||||
/* one ref is hold by the pool */
|
||||
fail_unless (GST_MINI_OBJECT_REFCOUNT (thread) == 2);
|
||||
|
||||
gst_rtsp_thread_stop (thread);
|
||||
g_object_unref (pool);
|
||||
|
@ -62,6 +64,8 @@ GST_START_TEST (test_pool_get_thread_reuse)
|
|||
fail_unless (thread2 != NULL);
|
||||
|
||||
fail_unless (thread == thread2);
|
||||
/* one ref is hold by the pool */
|
||||
fail_unless (GST_MINI_OBJECT_REFCOUNT (thread) == 3);
|
||||
|
||||
gst_rtsp_thread_stop (thread);
|
||||
gst_rtsp_thread_stop (thread2);
|
||||
|
|
Loading…
Reference in a new issue