gsettings: Emit glib logs on stderr, not stdout
authorScott Worley <scottworley@scottworley.com>
Mon, 14 Jun 2021 03:11:34 +0000 (20:11 -0700)
committerScott Worley <scottworley@scottworley.com>
Tue, 15 Jun 2021 18:46:20 +0000 (11:46 -0700)
Having G_MESSAGES_DEBUG=all set in the environment (a normal thing to do
when debugging Gnome troubles) causes gsettings-helper to emit a bunch
of helpful gnome debug logs (which is good), but before this change they
were printed on stdout rather than stderr (which was bad!).  Rather than
going somewhere the user could see, these log messages were being sent
to the pulesaudio server and interpreted as the src/modules/stdin-util.c
protocol.  pulseadio waits to see a '!' message from gsettings-helper
before continuing startup.  With the log messages mixed in messing up
the stdin-util protocol, pulseaudio never saw the '!' message, and so
never completed startup.

This simple fix relies on a recent glib > 2.68 (Mar 2021), so builds
against old versions of glib will still have this problem!  We consider
this good enough until some complains otherwise.

Fixes: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/1222
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/579>

src/modules/gsettings/gsettings-helper.c

index 1bf2f13..0b379ba 100644 (file)
@@ -85,6 +85,9 @@ int main(int argc, char *argv[]) {
 #if !GLIB_CHECK_VERSION(2,36,0)
     g_type_init();
 #endif
+#if GLIB_CHECK_VERSION(2,68,0)
+    g_log_writer_default_set_use_stderr(true);
+#endif
 
     /* gsettings-data-convert copies data from GConf to GSettings. The
      * conversion is defined in the pulseaudio.convert file. The conversion is