[sysprof] profiler: handle stop during startup more gracefully



commit f3ea9b2401acef94929c67192081cd7540429f53
Author: Christian Hergert <chergert redhat com>
Date:   Wed Feb 13 15:47:38 2019 -0800

    profiler: handle stop during startup more gracefully

 lib/profiler/sp-local-profiler.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/lib/profiler/sp-local-profiler.c b/lib/profiler/sp-local-profiler.c
index 3c3fc50..fda366a 100644
--- a/lib/profiler/sp-local-profiler.c
+++ b/lib/profiler/sp-local-profiler.c
@@ -74,6 +74,13 @@ typedef struct
    * feature of per-process vs whole-system.
    */
   guint whole_system : 1;
+
+  /*
+   * If we got a stop request after calling start() but before we have had
+   * a chance to settle, then we need to stop immediately after starting.
+   * We do this to avoid a more complex state machine (for now).
+   */
+  guint stop_after_starting : 1;
 } SpLocalProfilerPrivate;
 
 static void profiler_iface_init (SpProfilerInterface *iface);
@@ -191,7 +198,13 @@ sp_local_profiler_stop (SpProfiler *profiler)
 
   g_return_if_fail (SP_IS_LOCAL_PROFILER (self));
 
-  if (priv->is_stopping || (!priv->is_starting && !priv->is_running))
+  if (priv->is_starting)
+    {
+      priv->stop_after_starting = TRUE;
+      return;
+    }
+
+  if (priv->is_stopping || !priv->is_running)
     return;
 
   priv->is_stopping = TRUE;
@@ -444,7 +457,7 @@ sp_local_profiler_finish_startup (SpLocalProfiler *self)
    *
    * If we detect this, we stop immediately.
    */
-  if (priv->finished_or_failed->len == priv->sources->len)
+  if (priv->finished_or_failed->len == priv->sources->len || priv->stop_after_starting)
     sp_local_profiler_stop (SP_PROFILER (self));
 }
 


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