• Miloslav Trmač's avatar
    Fix a race condition when terminating runaway_killer_thread · 4d3ad674
    Miloslav Trmač authored
    The code used to call g_main_loop_quit() from the main thread, without
    having any guarantee that runaway_killer_thread_func() has even entered
    its g_main_loop_run().  If a main loop is not running,
    g_main_loop_quit() has no effect.
    
    This could occasionally be reproduced in
    test-polkitbackendjsauthority.c, which is creating several very
    short-lived PolkitBackendJSAuthority instances.  Real polkitd should not
    generally be affected, because it is using a single instance running for
    the life of the process ~ for the uptime of the system, enough time to
    enter the runaway_killer_thread main loop.
    
    To fix this, use g_idle_source_new () to make sure g_main_loop_quit ()
    is called from within the running main loop.
    
    Also, simplify the initialization of runaway_killer_thread by moving the
    creation of rkt_context and rkt_loop into the main thread; this makes
    the condition variable and its associated mutex completely unnecessary.
    
    Finally, only destroy rkt_timeout_pending_mutex _after_ the thread
    terminates; before, we were certain that rkt_source was destroyed by
    that time, but AFAICS that does not ensure that the rkt_on_timeout ()
    callback has already terminated.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=95513Signed-off-by: default avatarMiloslav Trmač <mitr@redhat.com>
    4d3ad674
Name
Last commit
Last update
actions Loading commit data...
buildutil Loading commit data...
data Loading commit data...
docs Loading commit data...
po Loading commit data...
src Loading commit data...
test Loading commit data...
.dir-locals.el Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
COPYING Loading commit data...
ChangeLog Loading commit data...
HACKING Loading commit data...
Makefile.am Loading commit data...
NEWS Loading commit data...
README Loading commit data...
autogen.sh Loading commit data...
configure.ac Loading commit data...
git.mk Loading commit data...