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