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.
This commit is contained in:
Dan Williams
2009-11-26 13:40:32 -08:00
parent 19e9c0cb48
commit 8dd2421e9c
2 changed files with 3 additions and 0 deletions

View File

@@ -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);
}

View File

@@ -28,6 +28,7 @@ struct _MMCallbackInfo {
MMCallbackInfoInvokeFn invoke_fn;
GCallback callback;
gboolean called;
gpointer user_data;
GError *error;