[gnome-builder/gnome-builder-3-20] workers: try to more gracefully shutdown worker processes
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/gnome-builder-3-20] workers: try to more gracefully shutdown worker processes
- Date: Fri, 6 May 2016 10:51:26 +0000 (UTC)
commit 0c12de31a6483df892a3dd98c21568e30ffc7faa
Author: Christian Hergert <chergert redhat com>
Date: Fri May 6 13:47:35 2016 +0300
workers: try to more gracefully shutdown worker processes
This still isn't "graceful" in that we don't notify the children processes
to cleanly exit, but it does more gracefully cleanup the GDBusServer.
Sometimes, it looks like the GDBusServer would get in a spinloop with
accepting connections on a closed file-descriptor.
Doing this forced cleanup should fix that.
https://bugzilla.gnome.org/show_bug.cgi?id=764823
libide/ide-application.c | 13 +++++++++++++
libide/ide-worker-manager.c | 18 ++++++++++++++++++
libide/ide-worker-manager.h | 1 +
libide/ide-worker-process.c | 15 +++++++--------
4 files changed, 39 insertions(+), 8 deletions(-)
---
diff --git a/libide/ide-application.c b/libide/ide-application.c
index 0d2626f..a85785e 100644
--- a/libide/ide-application.c
+++ b/libide/ide-application.c
@@ -385,6 +385,18 @@ ide_application_open (GApplication *application,
}
static void
+ide_application_shutdown (GApplication *application)
+{
+ IdeApplication *self = (IdeApplication *)application;
+
+ if (self->worker_manager != NULL)
+ ide_worker_manager_shutdown (self->worker_manager);
+
+ if (G_APPLICATION_CLASS (ide_application_parent_class)->shutdown)
+ G_APPLICATION_CLASS (ide_application_parent_class)->shutdown (application);
+}
+
+static void
ide_application_finalize (GObject *object)
{
IdeApplication *self = (IdeApplication *)object;
@@ -417,6 +429,7 @@ ide_application_class_init (IdeApplicationClass *klass)
g_app_class->local_command_line = ide_application_local_command_line;
g_app_class->open = ide_application_open;
g_app_class->startup = ide_application_startup;
+ g_app_class->shutdown = ide_application_shutdown;
}
static void
diff --git a/libide/ide-worker-manager.c b/libide/ide-worker-manager.c
index b8eceb5..91753ad 100644
--- a/libide/ide-worker-manager.c
+++ b/libide/ide-worker-manager.c
@@ -155,6 +155,9 @@ ide_worker_manager_finalize (GObject *object)
{
IdeWorkerManager *self = (IdeWorkerManager *)object;
+ if (self->dbus_server != NULL)
+ g_dbus_server_stop (self->dbus_server);
+
g_clear_pointer (&self->plugin_name_to_worker, g_hash_table_unref);
g_clear_object (&self->dbus_server);
@@ -193,6 +196,9 @@ ide_worker_manager_get_worker_process (IdeWorkerManager *self,
g_assert (IDE_IS_WORKER_MANAGER (self));
g_assert (plugin_name != NULL);
+ if (!self->plugin_name_to_worker || !self->dbus_server)
+ return NULL;
+
worker_process = g_hash_table_lookup (self->plugin_name_to_worker, plugin_name);
if (worker_process == NULL)
@@ -276,3 +282,15 @@ ide_worker_manager_new (void)
{
return g_object_new (IDE_TYPE_WORKER_MANAGER, NULL);
}
+
+void
+ide_worker_manager_shutdown (IdeWorkerManager *self)
+{
+ g_return_if_fail (IDE_IS_WORKER_MANAGER (self));
+
+ if (self->dbus_server != NULL)
+ g_dbus_server_stop (self->dbus_server);
+
+ g_clear_pointer (&self->plugin_name_to_worker, g_hash_table_unref);
+ g_clear_object (&self->dbus_server);
+}
diff --git a/libide/ide-worker-manager.h b/libide/ide-worker-manager.h
index c8e7ded..469643a 100644
--- a/libide/ide-worker-manager.h
+++ b/libide/ide-worker-manager.h
@@ -28,6 +28,7 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (IdeWorkerManager, ide_worker_manager, IDE, WORKER_MANAGER, GObject)
IdeWorkerManager *ide_worker_manager_new (void);
+void ide_worker_manager_shutdown (IdeWorkerManager *self);
void ide_worker_manager_get_worker_async (IdeWorkerManager *self,
const gchar *plugin_name,
GCancellable *cancellable,
diff --git a/libide/ide-worker-process.c b/libide/ide-worker-process.c
index dac6b1a..682706d 100644
--- a/libide/ide-worker-process.c
+++ b/libide/ide-worker-process.c
@@ -87,7 +87,7 @@ ide_worker_process_wait_check_cb (GObject *object,
{
GSubprocess *subprocess = (GSubprocess *)object;
g_autoptr(IdeWorkerProcess) self = user_data;
- GError *error = NULL;
+ g_autoptr(GError) error = NULL;
IDE_ENTRY;
@@ -96,7 +96,10 @@ ide_worker_process_wait_check_cb (GObject *object,
g_assert (G_IS_ASYNC_RESULT (result));
if (!g_subprocess_wait_check_finish (subprocess, result, &error))
- g_critical ("%s", error->message);
+ {
+ if (!self->quit)
+ g_warning ("%s", error->message);
+ }
g_clear_object (&self->subprocess);
@@ -190,13 +193,9 @@ ide_worker_process_quit (IdeWorkerProcess *self)
if (self->subprocess != NULL)
{
- if (!g_subprocess_get_if_exited (self->subprocess))
- {
- g_autoptr(GSubprocess) subprocess = self->subprocess;
+ g_autoptr(GSubprocess) subprocess = g_steal_pointer (&self->subprocess);
- self->subprocess = NULL;
- g_subprocess_force_exit (subprocess);
- }
+ g_subprocess_force_exit (subprocess);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]