summaryrefslogtreecommitdiff
path: root/dix/main.c
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@freedesktop.org>2009-01-16 13:58:20 -0800
committerJeremy Huddleston <jeremyhu@freedesktop.org>2009-01-16 13:58:20 -0800
commitca46c01869768a8661a9d8a71493ed5f0760a8ab (patch)
tree781a985ae1438e10aa8ab73773d1433de52ca86a /dix/main.c
parentb33905234025f005819c7e2acd653a3a0ecfeb82 (diff)
XQuartz: mieq: Wait for the server to finish initializing before letting other threads mieqEnqueue
Avoid possible race condition whereby one thread might call mieqEnqueue before InitAndStartDevices finishes (cherry picked from commit 94e417ac87a98cd5c6bf2d7c495d702748398931)
Diffstat (limited to 'dix/main.c')
-rw-r--r--dix/main.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/dix/main.c b/dix/main.c
index 4a062b7f1..069a17b66 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -233,6 +233,12 @@ static int indexForScanlinePad[ 65 ] = {
#endif
#ifdef XQUARTZ
+#include <pthread.h>
+
+BOOL serverInitComplete = FALSE;
+pthread_mutex_t serverInitCompleteMutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_cond_t serverInitCompleteCond = PTHREAD_COND_INITIALIZER;
+
int dix_main(int argc, char *argv[], char *envp[])
#else
int main(int argc, char *argv[], char *envp[])
@@ -377,6 +383,14 @@ int main(int argc, char *argv[], char *envp[])
}
}
+#ifdef XQUARTZ
+ /* Let the other threads know the server is done with its init */
+ pthread_mutex_lock(&serverInitCompleteMutex);
+ serverInitComplete = TRUE;
+ pthread_cond_broadcast(&serverInitCompleteCond);
+ pthread_mutex_unlock(&serverInitCompleteMutex);
+#endif
+
NotifyParentProcess();
Dispatch();