summaryrefslogtreecommitdiff
path: root/hw/xquartz/X11Application.m
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@freedesktop.org>2010-03-20 03:28:57 -0700
committerJeremy Huddleston <jeremyhu@apple.com>2010-03-21 21:56:39 -0700
commitd16bc8a3cdbe0e8b9cba836c7aa2ff7c0458049e (patch)
tree5efb349fc7905ca03978a0ddbc436ee247094bc1 /hw/xquartz/X11Application.m
parent9c9c3a85b094a3c7b2763a572715d710325091aa (diff)
XQuartz: xpbproxy: Cleanup xpbproxy threading
Confine xpbproxy to a single thread Runs inside its own CFRunLoop Signed-off-by: Jeremy Huddleston <jeremyhu@freedesktop.org>
Diffstat (limited to 'hw/xquartz/X11Application.m')
-rw-r--r--hw/xquartz/X11Application.m25
1 files changed, 22 insertions, 3 deletions
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 3faa1cb84..54066404e 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -52,7 +52,7 @@
#include <Xplugin.h>
// pbproxy/pbproxy.h
-extern BOOL xpbproxy_init (void);
+extern int xpbproxy_run (void);
#define DEFAULTS_FILE X11LIBDIR"/X11/xserver/Xquartz.plist"
@@ -908,6 +908,26 @@ environment the next time you start X11?", @"Startup xinitrc dialog");
[X11App prefs_synchronize];
}
+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) {
+ xpbproxy_run();
+
+ fprintf(stderr, "xpbproxy thread is terminating unexpectedly.\n");
+ return NULL;
+}
+
void X11ApplicationMain (int argc, char **argv, char **envp) {
NSAutoreleasePool *pool;
@@ -962,8 +982,7 @@ void X11ApplicationMain (int argc, char **argv, char **envp) {
*/
check_xinitrc();
- if(!xpbproxy_init())
- fprintf(stderr, "Error initializing xpbproxy\n");
+ create_thread(xpbproxy_x_thread, NULL);
#if XQUARTZ_SPARKLE
[[X11App controller] setup_sparkle];