From 7ca93301940647219dbed2d14fcd3f37e49fb477 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Tue, 18 Jun 2013 19:53:52 +0100 Subject: [PATCH] hw/xwin: Only add to XSetIOErrorHandler() handler chain once Only use XSetIOErrorHandler() to add to the global XSetIOErrorHandler() chain once. If we do it every restart, then we make a loop in the handler chain, and we end up with a thread spinning in that loop when the server shuts down... Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/winclipboard/thread.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/hw/xwin/winclipboard/thread.c b/hw/xwin/winclipboard/thread.c index 31986f6a0..a124e3e90 100644 --- a/hw/xwin/winclipboard/thread.c +++ b/hw/xwin/winclipboard/thread.c @@ -113,6 +113,7 @@ winClipboardProc(Bool fUseUnicode, char *szDisplay) Window iWindow = None; int iSelectError; Bool fShutdown = FALSE; + static Bool fErrorHandlerSet = FALSE; winDebug("winClipboardProc - Hello\n"); @@ -127,11 +128,15 @@ winClipboardProc(Bool fUseUnicode, char *szDisplay) ErrorF("winClipboardProc - Warning: Locale not supported by X.\n"); } - /* Set error handler */ - XSetErrorHandler(winClipboardErrorHandler); g_winClipboardProcThread = pthread_self(); - g_winClipboardOldIOErrorHandler = - XSetIOErrorHandler(winClipboardIOErrorHandler); + + /* Set error handler */ + if (!fErrorHandlerSet) { + XSetErrorHandler(winClipboardErrorHandler); + g_winClipboardOldIOErrorHandler = + XSetIOErrorHandler(winClipboardIOErrorHandler); + fErrorHandlerSet = TRUE; + } /* Set jump point for Error exits */ if (setjmp(g_jmpEntry)) {