This change makes logging initialization a bit less obscure.

Signed-off-by: Mikhail Gusarov <[email protected]>
---
 include/os.h |    1 +
 os/log.c     |   29 +++++++++++++++--------------
 os/osinit.c  |    8 +++++---
 3 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/include/os.h b/include/os.h
index efa202c..2c63491 100644
--- a/include/os.h
+++ b/include/os.h
@@ -526,6 +526,7 @@ typedef enum {
 } MessageType;
 
 extern _X_EXPORT const char *LogInit(const char *fname, const char *backup);
+extern           void LogFinishInit(void);
 extern _X_EXPORT void LogClose(void);
 extern _X_EXPORT Bool LogSetParameter(LogParameter param, int value);
 extern _X_EXPORT void LogVWrite(int verb, const char *f, va_list args);
diff --git a/os/log.c b/os/log.c
index f5dfdbf..52bb4aa 100644
--- a/os/log.c
+++ b/os/log.c
@@ -163,9 +163,21 @@ asm (".desc ___crashreporter_info__, 0x10");
 #endif
 
 /*
- * LogInit is called to start logging to a file.  It is also called (with
- * NULL arguments) when logging to a file is not wanted.  It must always be
- * called, otherwise log messages will continue to accumulate in a buffer.
+ * Dicard buffered log messages (if any) and stop further buffering.
+ */
+void
+LogFinishInit(void)
+{
+    if (saveBuffer) {
+       free(saveBuffer);       /* Must be free(), not free() */
+       saveBuffer = NULL;
+    }
+    bufferSize = 0;
+    needBuffer = FALSE;
+}
+
+/*
+ * LogInit is called to start logging to a file.
  *
  * %s, if present in the fname or backup strings, is expanded to the display
  * string.
@@ -218,17 +230,6 @@ LogInit(const char *fname, const char *backup)
        }
     }
 
-    /*
-     * Unconditionally free the buffer, and flag that the buffer is no longer
-     * needed.
-     */
-    if (saveBuffer && bufferSize > 0) {
-       free(saveBuffer);       /* Must be free(), not free() */
-       saveBuffer = NULL;
-       bufferSize = 0;
-    }
-    needBuffer = FALSE;
-
     return logFileName;
 }
 
diff --git a/os/osinit.c b/os/osinit.c
index c83c32c..0d409e2 100644
--- a/os/osinit.c
+++ b/os/osinit.c
@@ -300,11 +300,13 @@ OsInit(void)
     }
     TimerInit();
     OsVendorInit();
+
     /*
-     * No log file by default.  OsVendorInit() should call LogInit() with the
-     * log file name if logging to a file is desired.
+     * This call will disable further buffering of log messages. DDX should 
have
+     * initialized logging in OsVendorInit already.
      */
-    LogInit(NULL, NULL);
+    LogFinishInit();
+
     SmartScheduleInit ();
 }
 
-- 
1.7.1

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to