xserver: Branch 'xorg-server-1.4-apple' - 3 commits

Jeremy Huddleston jeremyhu at kemper.freedesktop.org
Fri Jan 2 11:00:19 PST 2009


 configure.ac                 |    2 +-
 hw/xquartz/X11Application.m  |   16 ++--------------
 hw/xquartz/pbproxy/main.m    |   29 ++++++++++++++++++++++++-----
 hw/xquartz/pbproxy/pbproxy.h |    1 +
 hw/xquartz/pbproxy/x-input.m |   21 ++-------------------
 5 files changed, 30 insertions(+), 39 deletions(-)

New commits:
commit 87163c9641632f3b37024ff48cfa50b4d2744b40
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Fri Jan 2 10:59:33 2009 -0800

    1.4.2-apple31

diff --git a/configure.ac b/configure.ac
index 76d4601..4d0f87c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,7 +26,7 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.57)
-AC_INIT([xorg-server], 1.4.2-apple30, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+AC_INIT([xorg-server], 1.4.2-apple31, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([dist-bzip2 foreign])
 AM_MAINTAINER_MODE
commit 49e59d32b88e4fad070f230b5efaa261b47f78db
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Fri Jan 2 10:58:40 2009 -0800

    XQuartz: pbproxy: Push dpy init and CFRunLoop hook setup into the pbproxy thread to avoid possible deadlock

diff --git a/hw/xquartz/pbproxy/main.m b/hw/xquartz/pbproxy/main.m
index 247ff74..5bc5182 100644
--- a/hw/xquartz/pbproxy/main.m
+++ b/hw/xquartz/pbproxy/main.m
@@ -68,7 +68,20 @@ static int x_error_handler (Display *dpy, XErrorEvent *errevent) {
     return 0;
 }
 
-BOOL xpbproxy_init (void) {
+static inline pthread_t create_thread(void *func, void *arg) {
+    pthread_attr_t attr;
+    pthread_t tid;
+    
+    pthread_attr_init(&attr);
+    pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
+    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+    pthread_create(&tid, &attr, func, arg);
+    pthread_attr_destroy(&attr);
+    
+    return tid;
+}
+
+static void *xpbproxy_x_thread(void *args) {
     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     size_t i;
 
@@ -89,7 +102,7 @@ BOOL xpbproxy_init (void) {
     if (xpbproxy_dpy == NULL) {
         fprintf (stderr, "xpbproxy: can't open default display\n");
         [pool release];
-        return FALSE;
+        return NULL;
     }
     
     XSetIOErrorHandler (x_io_error_handler);
@@ -99,7 +112,7 @@ BOOL xpbproxy_init (void) {
                                  &xpbproxy_apple_wm_error_base)) {
         fprintf (stderr, "xpbproxy: can't open AppleWM server extension\n");
         [pool release];
-        return FALSE;
+        return NULL;
     }
     
     xpbproxy_have_xfixes = XFixesQueryExtension(xpbproxy_dpy, &xpbproxy_xfixes_event_base, &xpbproxy_xfixes_error_base);
@@ -111,11 +124,17 @@ BOOL xpbproxy_init (void) {
     
     if(!xpbproxy_input_register()) {
         [pool release];
-        return FALSE;
+        return NULL;
     }
 
     [pool release];
-    
+ 
+    xpbproxy_input_loop();
+    return NULL;
+}
+
+BOOL xpbproxy_init (void) {
+    create_thread(xpbproxy_x_thread, NULL);
     return TRUE;
 }
 
diff --git a/hw/xquartz/pbproxy/pbproxy.h b/hw/xquartz/pbproxy/pbproxy.h
index d24d08b..a6798ef 100644
--- a/hw/xquartz/pbproxy/pbproxy.h
+++ b/hw/xquartz/pbproxy/pbproxy.h
@@ -76,6 +76,7 @@ extern BOOL xpbproxy_have_xfixes;
 
 /* from x-input.m */
 extern BOOL xpbproxy_input_register (void);
+extern void xpbproxy_input_loop();
 
 #ifdef DEBUG
 /* BEWARE: this can cause a string memory leak, according to the leaks program. */
diff --git a/hw/xquartz/pbproxy/x-input.m b/hw/xquartz/pbproxy/x-input.m
index acd01af..6ba30c6 100644
--- a/hw/xquartz/pbproxy/x-input.m
+++ b/hw/xquartz/pbproxy/x-input.m
@@ -50,19 +50,6 @@ BOOL xpbproxy_prefs_reload = NO;
 static pthread_mutex_t xpbproxy_dpy_rdy_lock = PTHREAD_MUTEX_INITIALIZER;
 static pthread_cond_t xpbproxy_dpy_rdy_cond = PTHREAD_COND_INITIALIZER;
 
-static inline pthread_t create_thread(void *func, void *arg) {
-    pthread_attr_t attr;
-    pthread_t tid;
-    
-    pthread_attr_init(&attr);
-    pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
-    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-    pthread_create(&tid, &attr, func, arg);
-    pthread_attr_destroy(&attr);
-    
-    return tid;
-}
-
 /* Timestamp when the X server last told us it's active */
 static Time last_activation_time;
 
@@ -101,7 +88,7 @@ static void x_event_apple_wm_notify(XAppleWMNotifyEvent *e) {
     }
 }
 
-static void *xpbproxy_input_thread(void *args) {
+void xpbproxy_input_loop() {
     pthread_mutex_lock(&xpbproxy_dpy_rdy_lock);
     while(true) {
         NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
@@ -153,8 +140,6 @@ static void *xpbproxy_input_thread(void *args) {
         
         pthread_cond_wait(&xpbproxy_dpy_rdy_cond, &xpbproxy_dpy_rdy_lock);
     }
-    
-    return NULL;
 }
 
 static BOOL add_input_socket (int sock, CFOptionFlags callback_types,
@@ -176,7 +161,7 @@ static BOOL add_input_socket (int sock, CFOptionFlags callback_types,
     if (*cf_source == NULL)
         return FALSE;
     
-    CFRunLoopAddSource (CFRunLoopGetCurrent (),
+    CFRunLoopAddSource (CFRunLoopGetMain (),
                         *cf_source, kCFRunLoopDefaultMode);
     return TRUE;
 }
@@ -197,8 +182,6 @@ static void x_input_callback (CFSocketRef sock, CFSocketCallBackType type,
 }
 
 BOOL xpbproxy_input_register(void) {
-    create_thread(xpbproxy_input_thread, NULL);
-
     return add_input_socket(ConnectionNumber(xpbproxy_dpy), kCFSocketReadCallBack,
                             x_input_callback, NULL, &xpbproxy_dpy_source);
 }
commit 5ac87d00b28e7d6f169be16195f8d444a528735b
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Fri Jan 2 10:36:43 2009 -0800

    Revert "XQuartz: Ignore mach IPC until the appkit thread is ready to avoid possible deadlock (this can be reversed once pbproxy uses server API)"
    
    Gonna try this a different way...
    
    This reverts commit 9eec2d3e3b4da2427a1c3a26538d36c4e8a7f1ed.

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 8530118..50212dc 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -69,8 +69,6 @@ static NSEventType keyState[NUM_KEYCODES];
 int X11EnableKeyEquivalents = TRUE, quartzFullscreenMenu = FALSE;
 int quartzHasRoot = FALSE, quartzEnableRootless = TRUE;
 
-static Bool appkitReady = FALSE;
-
 extern Bool noTestExtensions;
 
 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
@@ -123,15 +121,7 @@ static void init_ports (void) {
 static void message_kit_thread (SEL selector, NSObject *arg) {
     message msg;
     kern_return_t r;
-
-    if(!appkitReady) {
-#if 0
-        ErrorF("%s: mach_msg failed: Appkit thread not ready\n", __FUNCTION__);
-        spewCallStack();
-#endif
-        return;
-    }
-
+	
     msg.hdr.msgh_bits = MACH_MSGH_BITS (MACH_MSG_TYPE_MAKE_SEND, 0);
     msg.hdr.msgh_size = sizeof (msg);
     msg.hdr.msgh_remote_port = _port;
@@ -936,9 +926,7 @@ void X11ApplicationMain (int argc, char **argv, char **envp) {
     
     if(!xpbproxy_init())
         fprintf(stderr, "Error initializing xpbproxy\n");
-
-    appkitReady = TRUE;
-
+           
     [NSApp run];
     /* not reached */
 }


More information about the xorg-commit mailing list