From 8dd2421e9c7c2d8afa5af4080eabed41c5689d81 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 26 Nov 2009 13:40:32 -0800 Subject: core: don't allow double-scheduled callbacks If the modem becomes invalid (it crashes and resets, for example) the callback-info's modem_destroyed_cb() function will handle cleanup. Buf if the callback-info's callback does more work than just returning the result (like simple_state_machine) it could double-schedule the callback. Don't let that happen. We need better modem-removal handling, but this fixes a crash for now. --- src/mm-callback-info.c | 2 ++ src/mm-callback-info.h | 1 + 2 files changed, 3 insertions(+) (limited to 'src') diff --git a/src/mm-callback-info.c b/src/mm-callback-info.c index 0aca55da..089f0b73 100644 --- a/src/mm-callback-info.c +++ b/src/mm-callback-info.c @@ -67,6 +67,7 @@ callback_info_done (gpointer user_data) MMCallbackInfo *info = (MMCallbackInfo *) user_data; info->pending_id = 0; + info->called = TRUE; if (info->invoke_fn && info->callback) info->invoke_fn (info); @@ -94,6 +95,7 @@ mm_callback_info_schedule (MMCallbackInfo *info) { g_return_if_fail (info != NULL); g_return_if_fail (info->pending_id == 0); + g_return_if_fail (info->called == FALSE); info->pending_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, callback_info_do, info, callback_info_done); } diff --git a/src/mm-callback-info.h b/src/mm-callback-info.h index 591ac86e..783e1282 100644 --- a/src/mm-callback-info.h +++ b/src/mm-callback-info.h @@ -28,6 +28,7 @@ struct _MMCallbackInfo { MMCallbackInfoInvokeFn invoke_fn; GCallback callback; + gboolean called; gpointer user_data; GError *error; -- cgit v1.2.3-70-g09d2