[sysprof/wip/chergert/sysprof-3] helpers: try harder to avoid D-Bus to daemon
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof/wip/chergert/sysprof-3] helpers: try harder to avoid D-Bus to daemon
- Date: Wed, 22 May 2019 06:52:09 +0000 (UTC)
commit 84c708890621472d640dfe2360e1273fcc5163cf
Author: Christian Hergert <chergert redhat com>
Date: Tue May 21 21:56:39 2019 -0700
helpers: try harder to avoid D-Bus to daemon
src/libsysprof/sysprof-helpers.c | 42 ++++++++++++++++++++++++++++++++++------
1 file changed, 36 insertions(+), 6 deletions(-)
---
diff --git a/src/libsysprof/sysprof-helpers.c b/src/libsysprof/sysprof-helpers.c
index 3f5b0e7..485a45b 100644
--- a/src/libsysprof/sysprof-helpers.c
+++ b/src/libsysprof/sysprof-helpers.c
@@ -344,11 +344,8 @@ sysprof_helpers_get_proc_file (SysprofHelpers *self,
g_return_val_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable), FALSE);
/* try locally first if we can */
- if (!g_file_test ("/.flatpak-info", G_FILE_TEST_EXISTS))
- {
- if (helpers_get_proc_file (path, contents, &len))
- return TRUE;
- }
+ if (helpers_can_see_pids ())
+ return helpers_get_proc_file (path, contents, &len);
if (self->proxy != NULL)
{
@@ -644,7 +641,7 @@ sysprof_helpers_get_process_info (SysprofHelpers *self,
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
g_assert (info != NULL);
- if (no_proxy)
+ if (no_proxy || helpers_can_see_pids ())
{
*info = helpers_get_process_info (attributes);
return TRUE;
@@ -672,6 +669,32 @@ sysprof_helpers_get_process_info_cb (IpcService *service,
g_task_return_pointer (task, g_steal_pointer (&info), (GDestroyNotify)g_variant_unref);
}
+static void
+sysprof_helpers_get_process_info_worker (GTask *task,
+ gpointer source_object,
+ gpointer task_data,
+ GCancellable *cancellable)
+{
+ const gchar *attributes = task_data;
+ g_autoptr(GError) error = NULL;
+ g_autoptr(GVariant) ret = NULL;
+
+ g_assert (G_IS_TASK (task));
+ g_assert (SYSPROF_IS_HELPERS (source_object));
+ g_assert (attributes != NULL);
+ g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
+
+ if ((ret = helpers_get_process_info (attributes)))
+ g_task_return_pointer (task,
+ g_steal_pointer (&ret),
+ (GDestroyNotify) g_variant_unref);
+ else
+ g_task_return_new_error (task,
+ G_IO_ERROR,
+ G_IO_ERROR_FAILED,
+ "Failed to retrieve proc info");
+}
+
void
sysprof_helpers_get_process_info_async (SysprofHelpers *self,
const gchar *attributes,
@@ -688,6 +711,13 @@ sysprof_helpers_get_process_info_async (SysprofHelpers *self,
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, sysprof_helpers_get_process_info_async);
+ if (helpers_can_see_pids ())
+ {
+ g_task_set_task_data (task, g_strdup (attributes), g_free);
+ g_task_run_in_thread (task, sysprof_helpers_get_process_info_worker);
+ return;
+ }
+
ipc_service_call_get_process_info (self->proxy,
attributes,
cancellable,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]