Blame SOURCES/0001-Don-t-schedule-dleyna_task_processor_t-on_quit_cb-mo.patch

ecc610
From dc8858944f523961edcaea5b2e5f73dfb7d14907 Mon Sep 17 00:00:00 2001
ecc610
From: Debarshi Ray <debarshir@freedesktop.org>
ecc610
Date: Thu, 15 Sep 2016 17:06:56 +0200
ecc610
Subject: [PATCH] Don't schedule dleyna_task_processor_t->on_quit_cb more than
ecc610
 once
ecc610
ecc610
Even if there are some running tasks, cancelling all the queues will
ecc610
set processor->running_tasks to zero. It will call
ecc610
dleyna_task_queue_task_completed for each running task, which will
ecc610
keep decrementing processor->running_tasks and schedule the on_quit_cb
ecc610
handler once it is zero. Therefore, it is meaningless to check the
ecc610
value of processor->running_tasks after prv_cancel_all_queues.
ecc610
Instead, we should do it before.
ecc610
ecc610
Otherwise, it can confuse client code which doesn't expect to have the
ecc610
on_quit_cb handler invoked multiple times. For example, it causes
ecc610
dleyna-render-service to crash with this backtrace:
ecc610
ecc610
%0  __GI_raise (sig=sig@entry=6)
ecc610
    at ../sysdeps/unix/sysv/linux/raise.c:55
ecc610
%1  __GI_abort () at abort.c:89
ecc610
%2  __libc_message (do_abort=do_abort@entry=2,
ecc610
                    fmt=fmt@entry=0x7f89f83f0e20 "*** Error in `%s':
ecc610
                                                  %s: 0x%s ***\n")
ecc610
    at ../sysdeps/posix/libc_fatal.c:175
ecc610
%3  malloc_printerr (ar_ptr=<optimized out>,
ecc610
                     ptr=<optimized out>,
ecc610
                     str=0x7f89f83f0ee8 "double free or corruption
ecc610
                                         (fasttop)",
ecc610
                     action=3)
ecc610
    at malloc.c:5000
ecc610
%4  _int_free (av=<optimized out>,
ecc610
               p=<optimized out>,
ecc610
               have_lock=0)
ecc610
    at malloc.c:3861
ecc610
%5  __GI___libc_free (mem=<optimized out>) at malloc.c:2962
ecc610
%6  g_free (mem=0x558aa23b0000) at gmem.c:192
ecc610
%7  dlr_upnp_delete (upnp=<optimized out>) at upnp.c:423
ecc610
%8  prv_control_point_stop_service () at server.c:725
ecc610
%9  prv_context_quit_cb (user_data=<optimized out>)
ecc610
    at libdleyna/core/main-loop.c:61
ecc610
%10 g_main_dispatch (context=0x558aa237a140) at gmain.c:3122
ecc610
%11 g_main_context_dispatch (context=context@entry=0x558aa237a140)
ecc610
    at gmain.c:3737
ecc610
%12 g_main_context_iterate (context=0x558aa237a140,
ecc610
                            block=block@entry=1,
ecc610
                            dispatch=dispatch@entry=1,
ecc610
                            self=<optimized out>)
ecc610
    at gmain.c:3808
ecc610
%13 g_main_loop_run (loop=0x558aa23aecc0) at gmain.c:4002
ecc610
%14 dleyna_main_loop_start (server=<optimized out>,
ecc610
                            control_point=<optimized out>,
ecc610
                            user_data=0x0)
ecc610
    at libdleyna/core/main-loop.c:155
ecc610
%16 _start ()
ecc610
ecc610
https://bugzilla.redhat.com/show_bug.cgi?id=1251366
ecc610
---
ecc610
 libdleyna/core/task-processor.c | 4 ++--
ecc610
 1 file changed, 2 insertions(+), 2 deletions(-)
ecc610
ecc610
diff --git a/libdleyna/core/task-processor.c b/libdleyna/core/task-processor.c
ecc610
index 62778971d7a6..6d7f5b87de3d 100644
ecc610
--- a/libdleyna/core/task-processor.c
ecc610
+++ b/libdleyna/core/task-processor.c
ecc610
@@ -253,11 +253,11 @@ void dleyna_task_processor_set_quitting(dleyna_task_processor_t *processor)
ecc610
 
ecc610
 	processor->quitting = TRUE;
ecc610
 
ecc610
-	prv_cancel_all_queues(processor);
ecc610
-
ecc610
 	if (processor->running_tasks == 0)
ecc610
 		g_idle_add(processor->on_quit_cb, NULL);
ecc610
 
ecc610
+	prv_cancel_all_queues(processor);
ecc610
+
ecc610
 	DLEYNA_LOG_DEBUG("Exit");
ecc610
 }
ecc610
 
ecc610
-- 
ecc610
2.7.4
ecc610