Skip to content
Snippets Groups Projects
Commit 63c8f509 authored by Aleksander Morgado's avatar Aleksander Morgado
Browse files

iface-modem-time: make sure timezone context is cleaned up properly

If we're going to overwrite the timezone context, make sure everything
is cleaned up, including the signal handler. Otherwise, we may end up
running the signal handler without a context attached:

    (gdb) bt
    #0  network_timezone_state_changed (self=0x6aa1e8) at mm-iface-modem-time.c:266
    #1  0x76a8d418 in g_closure_invoke (closure=0x6c9810, return_value=0x0, return_value@entry=0x1, n_param_values=2, param_values=0x7edb58c0, param_values@entry=0x6cdab8,
        invocation_hint=invocation_hint@entry=0x7edb585c) at gclosure.c:804
    #2  0x76a9e674 in signal_emit_unlocked_R (node=node@entry=0x6794d0, detail=0, detail@entry=391, instance=instance@entry=0x6aa1e8, emission_return=0x6794a8, emission_return@entry=0x0,
        instance_and_params=instance_and_params@entry=0x7edb58c0) at gsignal.c:3629
    #3  0x76aa31f4 in g_signal_emit_valist (instance=instance@entry=0x6aa1e8, signal_id=signal_id@entry=1, detail=detail@entry=6767564, var_args=..., var_args@entry=...) at gsignal.c:3385
    #4  0x76aa34ec in g_signal_emit (instance=instance@entry=0x6aa1e8, signal_id=signal_id@entry=1, detail=391) at gsignal.c:3441
    #5  0x76a91698 in g_object_dispatch_properties_changed (object=0x6aa1e8, n_pspecs=1, pspecs=<optimized out>) at gobject.c:1062
    #6  0x76a90e7c in g_object_notify_queue_thaw (object=object@entry=0x6aa1e8, nqueue=nqueue@entry=0x75409418) at gobject.c:296
    #7  0x76a9470c in g_object_set_valist (object=object@entry=0x6aa1e8, first_property_name=first_property_name@entry=0xad566 "iface-modem-state", var_args=..., var_args@entry=...) at gobject.c:2171
    #8  0x76a94b18 in g_object_set (_object=_object@entry=0x6aa1e8, first_property_name=0xad566 "iface-modem-state") at gobject.c:2275
    #9  0x0004b8a4 in __iface_modem_update_state_internal (self=0x6aa1e8, new_state=MM_MODEM_STATE_DISABLED, reason=MM_MODEM_STATE_CHANGE_REASON_USER_REQUESTED, failed_reason=MM_MODEM_STATE_FAILED_REASON_NONE)
        at mm-iface-modem.c:1487
    #10 0x0007047c in disabling_context_free (ctx=0x6ba850) at mm-broadband-modem.c:9053
    #11 0x76b4e538 in g_task_finalize (object=0x682488) at gtask.c:636
    #12 0x76a92800 in g_object_unref (_object=0x682488) at gobject.c:3183
    #13 0x00072154 in iface_modem_disable_ready (self=0x6aa1e8, result=0x7011b0, task=0x682488) at mm-broadband-modem.c:9101
    #14 0x76b4e6ec in g_task_return_now (task=0x7011b0) at gtask.c:1107
    #15 0x76b4e720 in complete_in_idle_cb (task=0x7011b0) at gtask.c:1121
    #16 0x7694d144 in g_main_dispatch (context=0x6765a8) at gmain.c:3154
    #17 g_main_context_dispatch (context=context@entry=0x6765a8) at gmain.c:3769
    #18 0x7694d40c in g_main_context_iterate (context=0x6765a8, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3840
    #19 0x7694d838 in g_main_loop_run (loop=0x6750d0) at gmain.c:4034
    #20 0x0002bec0 in main (argc=<optimized out>, argv=<optimized out>) at main.c:181

(cherry picked from commit a77beaa2)
parent 579f1d59
No related branches found
No related tags found
No related merge requests found
......@@ -280,6 +280,22 @@ network_timezone_state_changed (MMIfaceModemTime *self)
}
}
static void
stop_network_timezone (MMIfaceModemTime *self)
{
NetworkTimezoneContext *ctx;
ctx = (NetworkTimezoneContext *) g_object_get_qdata (G_OBJECT (self), network_timezone_context_quark);
if (ctx) {
/* Remove signal connection and then trigger context free */
if (ctx->state_changed_id) {
g_signal_handler_disconnect (self, ctx->state_changed_id);
ctx->state_changed_id = 0;
}
g_object_set_qdata (G_OBJECT (self), network_timezone_context_quark, NULL);
}
}
static void
start_network_timezone (MMIfaceModemTime *self)
{
......@@ -295,6 +311,9 @@ start_network_timezone (MMIfaceModemTime *self)
if (G_UNLIKELY (!network_timezone_context_quark))
network_timezone_context_quark = (g_quark_from_static_string (NETWORK_TIMEZONE_CONTEXT_TAG));
/* Cleanup context properly if it already exists, including the signal handler */
stop_network_timezone (self);
ctx = g_new0 (NetworkTimezoneContext, 1);
g_object_set_qdata_full (G_OBJECT (self),
network_timezone_context_quark,
......@@ -315,22 +334,6 @@ start_network_timezone (MMIfaceModemTime *self)
start_network_timezone_poll (self);
}
static void
stop_network_timezone (MMIfaceModemTime *self)
{
NetworkTimezoneContext *ctx;
ctx = (NetworkTimezoneContext *) g_object_get_qdata (G_OBJECT (self), network_timezone_context_quark);
if (ctx) {
/* Remove signal connection and then trigger context free */
if (ctx->state_changed_id) {
g_signal_handler_disconnect (self, ctx->state_changed_id);
ctx->state_changed_id = 0;
}
g_object_set_qdata (G_OBJECT (self), network_timezone_context_quark, NULL);
}
}
/*****************************************************************************/
void
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment