summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@apple.com>2011-05-14 16:11:32 -0700
committerJeremy Huddleston <jeremyhu@apple.com>2011-05-16 18:47:20 -0700
commit69e3527e257af2aae82449bf0e0e7846ccd1ce0c (patch)
tree031091d9695fa7b08da9d1c04d4267d314af40af
parent0a61aca1ed036b17cab48725eb6ab4d860c9aad8 (diff)
XQuartz: Don't call mieqEnqueue during server shutdown
Found-by: GuardMalloc Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com> (cherry picked from commit 25191648b8db87735a99243697f73036255c1eb6)
-rw-r--r--dix/main.c25
-rw-r--r--hw/xquartz/pbproxy/app-main.m6
-rw-r--r--hw/xquartz/pbproxy/main.m16
-rw-r--r--mi/mieq.c16
4 files changed, 35 insertions, 28 deletions
diff --git a/dix/main.c b/dix/main.c
index 692bec1c5..e20ffd649 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -120,9 +120,9 @@ extern void Dispatch(void);
#ifdef XQUARTZ
#include <pthread.h>
-BOOL serverInitComplete = FALSE;
-pthread_mutex_t serverInitCompleteMutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_cond_t serverInitCompleteCond = PTHREAD_COND_INITIALIZER;
+BOOL serverRunning = FALSE;
+pthread_mutex_t serverRunningMutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_cond_t serverRunningCond = PTHREAD_COND_INITIALIZER;
int dix_main(int argc, char *argv[], char *envp[]);
@@ -275,18 +275,25 @@ 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);
+ /* Let the other threads know the server is done with its init */
+ pthread_mutex_lock(&serverRunningMutex);
+ serverRunning = TRUE;
+ pthread_cond_broadcast(&serverRunningCond);
+ pthread_mutex_unlock(&serverRunningMutex);
#endif
NotifyParentProcess();
Dispatch();
- UndisplayDevices();
+#ifdef XQUARTZ
+ /* Let the other threads know the server is no longer running */
+ pthread_mutex_lock(&serverRunningMutex);
+ serverRunning = FALSE;
+ pthread_mutex_unlock(&serverRunningMutex);
+#endif
+
+ UndisplayDevices();
/* Now free up whatever must be freed */
if (screenIsSaved == SCREEN_SAVER_ON)
diff --git a/hw/xquartz/pbproxy/app-main.m b/hw/xquartz/pbproxy/app-main.m
index b00e90a6d..0e85101fd 100644
--- a/hw/xquartz/pbproxy/app-main.m
+++ b/hw/xquartz/pbproxy/app-main.m
@@ -39,9 +39,9 @@ CFStringRef app_prefs_domain_cfstr;
/* Stubs */
char *display = NULL;
-BOOL serverInitComplete = YES;
-pthread_mutex_t serverInitCompleteMutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_cond_t serverInitCompleteCond = PTHREAD_COND_INITIALIZER;
+BOOL serverRunning = YES;
+pthread_mutex_t serverRunningMutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_cond_t serverRunningCond = PTHREAD_COND_INITIALIZER;
static void signal_handler (int sig) {
switch(sig) {
diff --git a/hw/xquartz/pbproxy/main.m b/hw/xquartz/pbproxy/main.m
index bb0646502..f300c37c2 100644
--- a/hw/xquartz/pbproxy/main.m
+++ b/hw/xquartz/pbproxy/main.m
@@ -47,17 +47,17 @@ BOOL xpbproxy_is_standalone = NO;
x_selection *_selection_object;
-extern BOOL serverInitComplete;
-extern pthread_mutex_t serverInitCompleteMutex;
-extern pthread_cond_t serverInitCompleteCond;
+extern BOOL serverRunning;
+extern pthread_mutex_t serverRunningMutex;
+extern pthread_cond_t serverRunningCond;
static inline void wait_for_server_init(void) {
/* If the server hasn't finished initializing, wait for it... */
- if(!serverInitComplete) {
- pthread_mutex_lock(&serverInitCompleteMutex);
- while(!serverInitComplete)
- pthread_cond_wait(&serverInitCompleteCond, &serverInitCompleteMutex);
- pthread_mutex_unlock(&serverInitCompleteMutex);
+ if(!serverRunning) {
+ pthread_mutex_lock(&serverRunningMutex);
+ while(!serverRunning)
+ pthread_cond_wait(&serverRunningCond, &serverRunningMutex);
+ pthread_mutex_unlock(&serverRunningMutex);
}
}
diff --git a/mi/mieq.c b/mi/mieq.c
index 01da52a6c..cd1e47f63 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -83,17 +83,17 @@ static EventQueueRec miEventQueue;
#include <pthread.h>
static pthread_mutex_t miEventQueueMutex = PTHREAD_MUTEX_INITIALIZER;
-extern BOOL serverInitComplete;
-extern pthread_mutex_t serverInitCompleteMutex;
-extern pthread_cond_t serverInitCompleteCond;
+extern BOOL serverRunning;
+extern pthread_mutex_t serverRunningMutex;
+extern pthread_cond_t serverRunningCond;
static inline void wait_for_server_init(void) {
/* If the server hasn't finished initializing, wait for it... */
- if(!serverInitComplete) {
- pthread_mutex_lock(&serverInitCompleteMutex);
- while(!serverInitComplete)
- pthread_cond_wait(&serverInitCompleteCond, &serverInitCompleteMutex);
- pthread_mutex_unlock(&serverInitCompleteMutex);
+ if(!serverRunning) {
+ pthread_mutex_lock(&serverRunningMutex);
+ while(!serverRunning)
+ pthread_cond_wait(&serverRunningCond, &serverRunningMutex);
+ pthread_mutex_unlock(&serverRunningMutex);
}
}
#endif