Workaround file description leak from e_source_registry_authenticate_sync()
authorMilan Crha <mcrha@redhat.com>
Wed, 12 Dec 2012 22:27:28 +0000 (23:27 +0100)
committerMilan Crha <mcrha@redhat.com>
Wed, 12 Dec 2012 22:27:28 +0000 (23:27 +0100)
This workarounds a file descriptor leak (a GMainContext leak) partly
caused by GDBusConnection. See bug #690126 for more details:
https://bugzilla.gnome.org/show_bug.cgi?id=690126

It influeces also EUserPrompter.

libebackend/e-user-prompter.c
libedataserver/e-source-registry.c

index c1b32f5..2f4df0b 100644 (file)
@@ -250,7 +250,14 @@ user_prompter_prompt_thread (GSimpleAsyncResult *simple,
 
        if (!dbus_prompter) {
                g_main_context_pop_thread_default (main_context);
+
+               /* Make sure the main_context doesn't have pending operations;
+                  workarounds https://bugzilla.gnome.org/show_bug.cgi?id=690126 */
+               while (g_main_context_pending (main_context))
+                       g_main_context_iteration (main_context, FALSE);
+
                g_main_context_unref (main_context);
+
                g_dbus_error_strip_remote_error (local_error);
                g_simple_async_result_take_error (simple, local_error);
                return;
@@ -260,12 +267,20 @@ user_prompter_prompt_thread (GSimpleAsyncResult *simple,
                async_data->response_callback, async_data);
 
        if (!async_data->invoke (dbus_prompter, async_data, cancellable, &local_error)) {
+               g_signal_handler_disconnect (dbus_prompter, handler_id);
+               g_object_unref (dbus_prompter);
+
                g_main_context_pop_thread_default (main_context);
+
+               /* Make sure the main_context doesn't have pending operations;
+                  workarounds https://bugzilla.gnome.org/show_bug.cgi?id=690126 */
+               while (g_main_context_pending (main_context))
+                       g_main_context_iteration (main_context, FALSE);
+
                g_main_context_unref (main_context);
+
                g_dbus_error_strip_remote_error (local_error);
                g_simple_async_result_take_error (simple, local_error);
-               g_signal_handler_disconnect (dbus_prompter, handler_id);
-               g_object_unref (dbus_prompter);
                return;
        }
 
@@ -280,6 +295,12 @@ user_prompter_prompt_thread (GSimpleAsyncResult *simple,
        g_object_unref (dbus_prompter);
 
        g_main_context_pop_thread_default (main_context);
+
+       /* Make sure the main_context doesn't have pending operations;
+          workarounds https://bugzilla.gnome.org/show_bug.cgi?id=690126 */
+       while (g_main_context_pending (main_context))
+               g_main_context_iteration (main_context, FALSE);
+
        g_main_context_unref (main_context);
 }
 
index 0d83d98..93ae50b 100644 (file)
@@ -1772,6 +1772,12 @@ e_source_registry_authenticate_sync (ESourceRegistry *registry,
 
 exit:
        g_main_context_pop_thread_default (main_context);
+
+       /* Make sure the main_context doesn't have pending operations;
+          workarounds https://bugzilla.gnome.org/show_bug.cgi?id=690126 */
+       while (g_main_context_pending (main_context))
+               g_main_context_iteration (main_context, FALSE);
+
        g_main_context_unref (main_context);
 
        return success;