[Spice-devel] [spice-gtk 1/2] Fix --spice-debug

Christophe Fergeau cfergeau at redhat.com
Wed Oct 16 18:34:54 CEST 2013


If spice_util_set_debug() gets called before spice_util_get_debug(),
then the value set using spice_util_set_debug() will be overridden
by the result of g_getenv("SPICE_DEBUG") != NULL the first time
spice_util_get_debug() is called.

This causes remote-viewer --spice-debug to not enable debug as
advertised.

An alternate fix would have been to set debug_once.status to
G_ONCE_STATUS_READY but then we would lose the thread-safety
guarantees GOnce gives us.
---
 gtk/spice-util.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/gtk/spice-util.c b/gtk/spice-util.c
index 4372f28..82c5faa 100644
--- a/gtk/spice-util.c
+++ b/gtk/spice-util.c
@@ -49,6 +49,13 @@ static GOnce debug_once = G_ONCE_INIT;
  **/
 void spice_util_set_debug(gboolean enabled)
 {
+    /* Make sure debug_once has been initialised
+     * with the value of SPICE_DEBUG already, otherwise
+     * spice_util_get_debug() may overwrite the value
+     * that was just set using spice_util_set_debug()
+     */
+    spice_util_get_debug();
+
 #if GLIB_CHECK_VERSION(2, 31, 0)
     if (enabled) {
         const gchar *doms = g_getenv("G_MESSAGES_DEBUG");
-- 
1.8.3.1



More information about the Spice-devel mailing list