diff options
author | Jeremy Huddleston <jeremyhu@apple.com> | 2011-04-21 15:11:52 -0700 |
---|---|---|
committer | Jeremy Huddleston <jeremyhu@apple.com> | 2011-04-21 23:56:18 -0700 |
commit | 7524dbd06113ec081eaa882aa54e03553ccf96aa (patch) | |
tree | 8ff975b36e0a9d6af8f351d040d651e29a07dd29 /hw | |
parent | b3d2164a0361f636bfe77b51456bee9213af4f13 (diff) |
XQuartz: Make the DarwinProcessFDAdditionQueue_thread wait 3 seconds to allow xinitrc to catch up
Previously, we weren't always waiting the full three seconds. This should
be better, but is still sub-optimal. We really want to start processing
these once a WM has been started.
http://xquartz.macosforge.org/trac/ticket/416
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/xquartz/darwinEvents.c | 22 | ||||
-rw-r--r-- | hw/xquartz/mach-startup/bundle-main.c | 17 |
2 files changed, 23 insertions, 16 deletions
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c index 16fec4a01..0853b7199 100644 --- a/hw/xquartz/darwinEvents.c +++ b/hw/xquartz/darwinEvents.c @@ -61,6 +61,7 @@ in this Software without prior written authorization from The Open Group. #include <unistd.h> #include <pthread.h> #include <errno.h> +#include <time.h> #include <IOKit/hidsystem/IOLLEvent.h> @@ -305,6 +306,27 @@ void DarwinListenOnOpenFD(int fd) { } static void DarwinProcessFDAdditionQueue_thread(void *args) { + /* TODO: Possibly adjust this to no longer be a race... maybe trigger this + * once a client connects and claims to be the WM. + * + * From ajax: + * There's already an internal callback chain for setting selection [in 1.5] + * ownership. See the CallSelectionCallback at the bottom of + * ProcSetSelectionOwner, and xfixes/select.c for an example of how to hook + * into it. + */ + + struct timespec sleep_for; + struct timespec sleep_remaining; + + sleep_for.tv_sec = 3; + sleep_for.tv_nsec = 0; + + ErrorF("X11.app: DarwinProcessFDAdditionQueue_thread: Sleeping to allow xinitrc to catchup.\n"); + while(nanosleep(&sleep_for, &sleep_remaining) != 0) { + sleep_for = sleep_remaining; + } + pthread_mutex_lock(&fd_add_lock); while(true) { while(fd_add_count) { diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c index 75b39392a..4c79cfb42 100644 --- a/hw/xquartz/mach-startup/bundle-main.c +++ b/hw/xquartz/mach-startup/bundle-main.c @@ -47,7 +47,6 @@ #include <sys/socket.h> #include <sys/un.h> -#include <sys/time.h> #include <fcntl.h> #include <mach/mach.h> @@ -204,7 +203,6 @@ static void socket_handoff_thread(void *arg) { socket_handoff_t *handoff_data = (socket_handoff_t *)arg; int launchd_fd = -1; int connected_fd; - unsigned remain; /* Now actually get the passed file descriptor from this connection * If we encounter an error, keep listening. @@ -227,20 +225,7 @@ static void socket_handoff_thread(void *arg) { close(handoff_data->fd); unlink(handoff_data->filename); free(handoff_data); - - /* TODO: Clean up this race better... giving xinitrc time to run... need to wait for 1.5 branch: - * - * From ajax: - * There's already an internal callback chain for setting selection [in 1.5] - * ownership. See the CallSelectionCallback at the bottom of - * ProcSetSelectionOwner, and xfixes/select.c for an example of how to hook - * into it. - */ - - remain = 3000000; - fprintf(stderr, "X11.app: Received new $DISPLAY fd: %d ... sleeping to allow xinitrc to catchup.\n", launchd_fd); - while((remain = usleep(remain)) > 0); - + fprintf(stderr, "X11.app Handing off fd to server thread via DarwinListenOnOpenFD(%d)\n", launchd_fd); DarwinListenOnOpenFD(launchd_fd); } |