[sysprof] libsysprof: handle bus/proxy failure gracefully



commit c4eaa53f202896d44128f92bb252162bf371ad83
Author: Christian Hergert <chergert redhat com>
Date:   Thu Jan 2 10:31:12 2020 -0800

    libsysprof: handle bus/proxy failure gracefully

 src/libsysprof/sysprof-helpers.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
---
diff --git a/src/libsysprof/sysprof-helpers.c b/src/libsysprof/sysprof-helpers.c
index 4ba3dd0..c576f16 100644
--- a/src/libsysprof/sysprof-helpers.c
+++ b/src/libsysprof/sysprof-helpers.c
@@ -61,15 +61,12 @@ sysprof_helpers_init (SysprofHelpers *self)
 {
   g_autoptr(GDBusConnection) bus = NULL;
 
-  bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL);
-  g_return_if_fail (bus != NULL);
-
-  self->proxy = ipc_service_proxy_new_sync (bus,
-                                            G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START_AT_CONSTRUCTION,
-                                            "org.gnome.Sysprof3",
-                                            "/org/gnome/Sysprof3",
-                                            NULL, NULL);
-  g_return_if_fail (self->proxy != NULL);
+  if ((bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL)))
+    self->proxy = ipc_service_proxy_new_sync (bus,
+                                              G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START_AT_CONSTRUCTION,
+                                              "org.gnome.Sysprof3",
+                                              "/org/gnome/Sysprof3",
+                                              NULL, NULL);
 }
 
 SysprofHelpers *
@@ -178,7 +175,7 @@ sysprof_helpers_list_processes (SysprofHelpers  *self,
         return TRUE;
     }
 
-  if (ipc_service_call_list_processes_sync (self->proxy, &fixed_ar, cancellable, NULL))
+  if (self->proxy && ipc_service_call_list_processes_sync (self->proxy, &fixed_ar, cancellable, NULL))
     {
       const gint32 *data;
       gsize len;
@@ -191,6 +188,7 @@ sysprof_helpers_list_processes (SysprofHelpers  *self,
     }
 
   helpers_list_processes (processes, n_processes);
+
   return TRUE;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]