From 3382817cccc79780d3abf89ebbd117323b5a6703 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Wed, 12 Dec 2012 23:27:28 +0100 Subject: [PATCH] Workaround file description leak from e_source_registry_authenticate_sync() 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 | 25 +++++++++++++++++++++++-- libedataserver/e-source-registry.c | 6 ++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/libebackend/e-user-prompter.c b/libebackend/e-user-prompter.c index c1b32f5..2f4df0b 100644 --- a/libebackend/e-user-prompter.c +++ b/libebackend/e-user-prompter.c @@ -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); } diff --git a/libedataserver/e-source-registry.c b/libedataserver/e-source-registry.c index 0d83d98..93ae50b 100644 --- a/libedataserver/e-source-registry.c +++ b/libedataserver/e-source-registry.c @@ -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; -- 2.7.4