aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xwin
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-09-03 09:11:04 +0000
committermarha <marha@users.sourceforge.net>2010-09-03 09:11:04 +0000
commit917506f14358fb7ceb85e1b769c98951dccc9dd9 (patch)
tree6970d100feafc07a23384f824657c4410aec60aa /xorg-server/hw/xwin
parent1afeea5841dadba1e1c932be40f0012d370bd939 (diff)
downloadvcxsrv-917506f14358fb7ceb85e1b769c98951dccc9dd9.tar.gz
vcxsrv-917506f14358fb7ceb85e1b769c98951dccc9dd9.tar.bz2
vcxsrv-917506f14358fb7ceb85e1b769c98951dccc9dd9.zip
Make sure the process is killed when the clipboard thread is exited
Diffstat (limited to 'xorg-server/hw/xwin')
-rw-r--r--xorg-server/hw/xwin/winclipboardthread.c54
1 files changed, 40 insertions, 14 deletions
diff --git a/xorg-server/hw/xwin/winclipboardthread.c b/xorg-server/hw/xwin/winclipboardthread.c
index 5359c18ac..423a174f3 100644
--- a/xorg-server/hw/xwin/winclipboardthread.c
+++ b/xorg-server/hw/xwin/winclipboardthread.c
@@ -63,6 +63,9 @@ extern Window g_iClipboardWindow;
*/
static jmp_buf g_jmpEntry;
+static XIOErrorHandler g_winClipboardOldIOErrorHandler;
+static pthread_t g_winClipboardProcThread;
+
Bool g_fUnicodeSupport = FALSE;
Bool g_fUseUnicode = FALSE;
@@ -77,6 +80,8 @@ winClipboardErrorHandler (Display *pDisplay, XErrorEvent *pErr);
static int
winClipboardIOErrorHandler (Display *pDisplay);
+static void
+winClipboardThreadExit(void *arg);
/*
* Main thread function
@@ -103,6 +108,8 @@ winClipboardProc (void *pvNotUsed)
char szDisplay[512];
int iSelectError;
+ pthread_cleanup_push(&winClipboardThreadExit, NULL);
+
winDebug ("winClipboardProc - Hello\n");
/* Do we have Unicode support? */
@@ -126,6 +133,11 @@ winClipboardProc (void *pvNotUsed)
/* Save copy of HWND in screen privates */
g_hwndClipboard = hwnd;
+ /* Set error handler */
+ XSetErrorHandler (winClipboardErrorHandler);
+ g_winClipboardProcThread = pthread_self();
+ g_winClipboardOldIOErrorHandler = XSetIOErrorHandler (winClipboardIOErrorHandler);
+
/* Set jump point for Error exits */
iReturn = setjmp (g_jmpEntry);
@@ -148,10 +160,6 @@ winClipboardProc (void *pvNotUsed)
/* Use our generated cookie for authentication */
winSetAuthorization();
- /* Set error handler */
- XSetErrorHandler (winClipboardErrorHandler);
- XSetIOErrorHandler (winClipboardIOErrorHandler);
-
/* Initialize retry count */
iRetries = 0;
@@ -278,6 +286,7 @@ winClipboardProc (void *pvNotUsed)
goto thread_errorexit;
}
}
+
/* Pre-flush X events */
/*
* NOTE: Apparently you'll freeze if you don't do this,
@@ -429,12 +438,8 @@ winClipboardProc (void *pvNotUsed)
}
#endif
- g_iClipboardWindow = None;
- g_pClipboardDisplay = NULL;
- g_fClipboardLaunched = FALSE;
- g_fClipboardStarted = FALSE;
+ goto commonexit;
- return NULL;
thread_errorexit:
if (g_pClipboardDisplay && g_iClipboardWindow)
{
@@ -446,12 +451,16 @@ thread_errorexit:
winDebug ("winClipboardProc - XDestroyWindow succeeded.\n");
#endif
}
+ winDebug ("Clipboard thread died.\n");
+
+commonexit:
g_iClipboardWindow = None;
g_pClipboardDisplay = NULL;
g_fClipboardLaunched = FALSE;
g_fClipboardStarted = FALSE;
- //pthread_exit (NULL);
- winDebug ("Clipboard thread died.\n");
+
+ pthread_cleanup_pop(0);
+
return NULL;
}
@@ -494,8 +503,25 @@ winClipboardIOErrorHandler (Display *pDisplay)
{
ErrorF ("winClipboardIOErrorHandler!\n\n");
- /* Restart at the main entry point */
- longjmp (g_jmpEntry, WIN_JMP_ERROR_IO);
-
+ if (pthread_equal(pthread_self(),g_winClipboardProcThread))
+ {
+ /* Restart at the main entry point */
+ longjmp (g_jmpEntry, WIN_JMP_ERROR_IO);
+ }
+
+ if (g_winClipboardOldIOErrorHandler)
+ g_winClipboardOldIOErrorHandler(pDisplay);
+
return 0;
}
+
+/*
+ * winClipboardThreadExit - Thread exit handler
+ */
+
+static void
+winClipboardThreadExit(void *arg)
+{
+ /* clipboard thread has exited, stop server as well */
+ TerminateProcess(GetCurrentProcess(),1);
+}