[sysprof/wip/chergert/sysprof-3] libsysprof: add sync get_proc variant and fallbacks
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof/wip/chergert/sysprof-3] libsysprof: add sync get_proc variant and fallbacks
- Date: Thu, 9 May 2019 23:15:46 +0000 (UTC)
commit 393339da939e7e1fab6f839e554c1fb844e78369
Author: Christian Hergert <chergert redhat com>
Date: Thu May 9 16:14:59 2019 -0700
libsysprof: add sync get_proc variant and fallbacks
src/libsysprof/sysprof-helpers.c | 45 +++++++++++++++++++++++++++++++++++++---
src/libsysprof/sysprof-helpers.h | 5 +++++
2 files changed, 47 insertions(+), 3 deletions(-)
---
diff --git a/src/libsysprof/sysprof-helpers.c b/src/libsysprof/sysprof-helpers.c
index 0825095..0b1a10b 100644
--- a/src/libsysprof/sysprof-helpers.c
+++ b/src/libsysprof/sysprof-helpers.c
@@ -224,9 +224,47 @@ sysprof_helpers_get_proc_file_cb (IpcService *service,
g_assert (G_IS_TASK (task));
if (!ipc_service_call_get_proc_file_finish (service, &contents, result, &error))
- g_task_return_error (task, g_steal_pointer (&error));
- else
- g_task_return_pointer (task, g_steal_pointer (&contents), g_free);
+ {
+ const gchar *path = g_task_get_task_data (task);
+ gsize len;
+
+ if (!helpers_get_proc_file (path, &contents, &len))
+ {
+ g_task_return_error (task, g_steal_pointer (&error));
+ return;
+ }
+
+ g_clear_error (&error);
+ }
+
+ g_task_return_pointer (task, g_steal_pointer (&contents), g_free);
+}
+
+gboolean
+sysprof_helpers_get_proc_file (SysprofHelpers *self,
+ const gchar *path,
+ GCancellable *cancellable,
+ gchar **contents,
+ GError **error)
+{
+ gsize len;
+
+ g_return_val_if_fail (SYSPROF_IS_HELPERS (self), FALSE);
+ g_return_val_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable), FALSE);
+
+ if (self->proxy != NULL)
+ {
+ if (ipc_service_call_get_proc_file_sync (self->proxy, path, contents, cancellable, error))
+ return TRUE;
+ }
+
+ if (!helpers_get_proc_file (path, contents, &len))
+ return FALSE;
+
+ if (error != NULL)
+ g_clear_error (error);
+
+ return TRUE;
}
void
@@ -243,6 +281,7 @@ sysprof_helpers_get_proc_file_async (SysprofHelpers *self,
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, sysprof_helpers_list_processes_async);
+ g_task_set_task_data (task, g_strdup (path), g_free);
if (!fail_if_no_proxy (self, task))
ipc_service_call_get_proc_file (self->proxy,
diff --git a/src/libsysprof/sysprof-helpers.h b/src/libsysprof/sysprof-helpers.h
index 85da604..daa4aa0 100644
--- a/src/libsysprof/sysprof-helpers.h
+++ b/src/libsysprof/sysprof-helpers.h
@@ -42,6 +42,11 @@ gboolean sysprof_helpers_list_processes_finish (SysprofHelpers
gint32 **processes,
gsize *n_processes,
GError **error);
+gboolean sysprof_helpers_get_proc_file (SysprofHelpers *self,
+ const gchar *path,
+ GCancellable *cancellable,
+ gchar **contents,
+ GError **error);
void sysprof_helpers_get_proc_file_async (SysprofHelpers *self,
const gchar *path,
GCancellable *cancellable,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]