[Xquartz-changes] xserver: Branch 'master' - 2 commits

Jeremy Huddleston jeremyhu at freedesktop.org
Thu Aug 16 18:34:07 PDT 2012


 hw/xquartz/console_redirect.c         |   24 +++++++++++++++---------
 hw/xquartz/mach-startup/bundle-main.c |   17 +++++++++++++++++
 2 files changed, 32 insertions(+), 9 deletions(-)

New commits:
commit ce782286f8e69154e3e3f4d40e54e61f02e08aab
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Thu Aug 16 13:02:28 2012 -0700

    XQuartz: Use asl_log_descriptor on Mountain Lion
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index cabdf1e..b403662 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -563,8 +563,25 @@ setup_console_redirect(const char *bundle_id)
     free(asl_facility);
 
     asl_set_filter(aslc, ASL_FILTER_MASK_UPTO(ASL_LEVEL_WARNING));
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
+# if MAC_OS_X_VERSION_MIN_REQUIRED < 1080
+    if (asl_log_descriptor)
+# endif
+    {
+        asl_log_descriptor(aslc, NULL, ASL_LEVEL_INFO, STDOUT_FILENO, ASL_LOG_DESCRIPTOR_WRITE);
+        asl_log_descriptor(aslc, NULL, ASL_LEVEL_NOTICE, STDERR_FILENO, ASL_LOG_DESCRIPTOR_WRITE);
+    }
+# if MAC_OS_X_VERSION_MIN_REQUIRED < 1080
+    else {
+        xq_asl_capture_fd(aslc, NULL, ASL_LEVEL_INFO, STDOUT_FILENO);
+        xq_asl_capture_fd(aslc, NULL, ASL_LEVEL_NOTICE, STDERR_FILENO);
+    }
+# endif
+#else
     xq_asl_capture_fd(aslc, NULL, ASL_LEVEL_INFO, STDOUT_FILENO);
     xq_asl_capture_fd(aslc, NULL, ASL_LEVEL_NOTICE, STDERR_FILENO);
+#endif
 }
 
 static void
commit a32e01802ff1c938c0afe0cc007a273b9ada8610
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Thu Aug 16 15:43:34 2012 -0700

    XQuartz: console_redirect: Set the correct location for reading into the buffer
    
    Prior to this change, it was possible that a large message would have some
    of its data prepended to subsequent messages due to our not incorrectly
    setting the location to write into the buffer.
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/hw/xquartz/console_redirect.c b/hw/xquartz/console_redirect.c
index 91d693b..30e397a 100644
--- a/hw/xquartz/console_redirect.c
+++ b/hw/xquartz/console_redirect.c
@@ -110,27 +110,33 @@ _read_redirect(int fd, int flush)
         /* Increment our returned number read */
         total_read += nbytes;
 
-        nbytes += (aslr->w - aslr->buf);
-        aslr->buf[nbytes] = '\0';
+        /* Increment our write location */
+        aslr->w += nbytes;
+        aslr->w[0] = '\0';
 
         /* One line at a time */
-        for (p = aslr->buf; *p && (p - aslr->buf) < nbytes; p = s + 1) {
+        for (p = aslr->buf; p < aslr->w; p = s + 1) {
             // Find null or \n
             for (s = p; *s && *s != '\n'; s++) ;
             if (*s == '\n') {
                 *s = '\0';
+            }
+
+            if (s < aslr->w || aslr->buf == p) {
+                /* Either the first of multiple messages or one message which is larger than our buffer */
                 asl_log(aslr->asl, aslr->msg, aslr->level, "%s", p);
             }
-            else if (aslr->buf != p) {
+            else {
+                /* We reached the end of the buffer, move this chunk to the start. */
                 memmove(aslr->buf, p, BUF_SIZE - (p - aslr->buf));
                 aslr->w = aslr->buf + (s - p);
                 break;
             }
-            else if (nbytes == BUF_SIZE - 1) {
-                asl_log(aslr->asl, aslr->msg, aslr->level, "%s", p);
-                aslr->w = aslr->buf;
-                break;
-            }
+        }
+
+        if (p == aslr->w) {
+            /* Start writing at the beginning in the case where we flushed */
+            aslr->w = aslr->buf;
         }
     }
 


More information about the Xquartz-changes mailing list