hw/xwin: Hoist clipboard thread restart up one level
Hoist clipboard thread restart up one level. Note that currently g_fClipboardLaunched is set the first time in the winProcEstablishConnection wrapper, and subsequent times when the clipboard thread restarts itself. Try to clarify this and just set g_fClipboardLaunched before starting the thread. Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk> Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
This commit is contained in:
parent
0bb6eae4e3
commit
91e55691ef
|
@ -60,16 +60,12 @@
|
||||||
#ifdef HAS_DEVWINDOWS
|
#ifdef HAS_DEVWINDOWS
|
||||||
#define WIN_MSG_QUEUE_FNAME "/dev/windows"
|
#define WIN_MSG_QUEUE_FNAME "/dev/windows"
|
||||||
#endif
|
#endif
|
||||||
#define WIN_CONNECT_RETRIES 40
|
|
||||||
#define WIN_CONNECT_DELAY 4
|
|
||||||
#define WIN_JMP_OKAY 0
|
#define WIN_JMP_OKAY 0
|
||||||
#define WIN_JMP_ERROR_IO 2
|
#define WIN_JMP_ERROR_IO 2
|
||||||
#define WIN_LOCAL_PROPERTY "CYGX_CUT_BUFFER"
|
#define WIN_LOCAL_PROPERTY "CYGX_CUT_BUFFER"
|
||||||
#define WIN_XEVENTS_SUCCESS 0
|
#define WIN_XEVENTS_SUCCESS 0
|
||||||
#define WIN_XEVENTS_CONVERT 2
|
#define WIN_XEVENTS_CONVERT 2
|
||||||
#define WIN_XEVENTS_NOTIFY 3
|
#define WIN_XEVENTS_NOTIFY 3
|
||||||
#define WIN_CLIPBOARD_RETRIES 40
|
|
||||||
#define WIN_CLIPBOARD_DELAY 1
|
|
||||||
|
|
||||||
#define WM_WM_REINIT (WM_USER + 1)
|
#define WM_WM_REINIT (WM_USER + 1)
|
||||||
|
|
||||||
|
|
|
@ -31,9 +31,16 @@
|
||||||
#ifdef HAVE_XWIN_CONFIG_H
|
#ifdef HAVE_XWIN_CONFIG_H
|
||||||
#include <xwin-config.h>
|
#include <xwin-config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
#include "dixstruct.h"
|
#include "dixstruct.h"
|
||||||
#include "winclipboard.h"
|
#include "winclipboard.h"
|
||||||
|
|
||||||
|
#define WIN_CLIPBOARD_RETRIES 40
|
||||||
|
#define WIN_CLIPBOARD_DELAY 1
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Local typedefs
|
* Local typedefs
|
||||||
*/
|
*/
|
||||||
|
@ -58,6 +65,38 @@ extern Bool g_fClipboardStarted;
|
||||||
|
|
||||||
static pthread_t g_ptClipboardProc;
|
static pthread_t g_ptClipboardProc;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static void *
|
||||||
|
winClipboardThreadProc(void *arg)
|
||||||
|
{
|
||||||
|
int clipboardRestarts = 0;
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
++clipboardRestarts;
|
||||||
|
|
||||||
|
/* Flag that clipboard client has been launched */
|
||||||
|
g_fClipboardLaunched = TRUE;
|
||||||
|
|
||||||
|
winClipboardProc(arg);
|
||||||
|
|
||||||
|
/* checking if we need to restart */
|
||||||
|
if (clipboardRestarts >= WIN_CLIPBOARD_RETRIES) {
|
||||||
|
/* terminates clipboard thread but the main server still lives */
|
||||||
|
ErrorF("winClipboardProc - the clipboard thread has restarted %d times and seems to be unstable, disabling clipboard integration\n", clipboardRestarts);
|
||||||
|
g_fClipboard = FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
sleep(WIN_CLIPBOARD_DELAY);
|
||||||
|
ErrorF("winClipboardProc - trying to restart clipboard thread \n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Intialize the Clipboard module
|
* Intialize the Clipboard module
|
||||||
*/
|
*/
|
||||||
|
@ -74,7 +113,7 @@ winInitClipboard(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Spawn a thread for the Clipboard module */
|
/* Spawn a thread for the Clipboard module */
|
||||||
if (pthread_create(&g_ptClipboardProc, NULL, winClipboardProc, NULL)) {
|
if (pthread_create(&g_ptClipboardProc, NULL, winClipboardThreadProc, NULL)) {
|
||||||
/* Bail if thread creation failed */
|
/* Bail if thread creation failed */
|
||||||
ErrorF("winInitClipboard - pthread_create failed.\n");
|
ErrorF("winInitClipboard - pthread_create failed.\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -44,6 +44,9 @@
|
||||||
#endif
|
#endif
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
|
#define WIN_CONNECT_RETRIES 40
|
||||||
|
#define WIN_CONNECT_DELAY 4
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* References to external symbols
|
* References to external symbols
|
||||||
*/
|
*/
|
||||||
|
@ -61,7 +64,6 @@ extern Window g_iClipboardWindow;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static jmp_buf g_jmpEntry;
|
static jmp_buf g_jmpEntry;
|
||||||
static int clipboardRestarts = 0;
|
|
||||||
static XIOErrorHandler g_winClipboardOldIOErrorHandler;
|
static XIOErrorHandler g_winClipboardOldIOErrorHandler;
|
||||||
static pthread_t g_winClipboardProcThread;
|
static pthread_t g_winClipboardProcThread;
|
||||||
|
|
||||||
|
@ -104,7 +106,6 @@ winClipboardProc(void *pvNotUsed)
|
||||||
int iSelectError;
|
int iSelectError;
|
||||||
|
|
||||||
winDebug("winClipboardProc - Hello\n");
|
winDebug("winClipboardProc - Hello\n");
|
||||||
++clipboardRestarts;
|
|
||||||
|
|
||||||
/* Do we use Unicode clipboard? */
|
/* Do we use Unicode clipboard? */
|
||||||
fUseUnicode = g_fUnicodeClipboard;
|
fUseUnicode = g_fUnicodeClipboard;
|
||||||
|
@ -400,35 +401,6 @@ winClipboardProc(void *pvNotUsed)
|
||||||
g_pClipboardDisplay = NULL;
|
g_pClipboardDisplay = NULL;
|
||||||
g_hwndClipboard = NULL;
|
g_hwndClipboard = NULL;
|
||||||
|
|
||||||
/* checking if we need to restart */
|
|
||||||
if (clipboardRestarts >= WIN_CLIPBOARD_RETRIES) {
|
|
||||||
/* terminates clipboard thread but the main server still lives */
|
|
||||||
ErrorF
|
|
||||||
("winClipboardProc - the clipboard thread has restarted %d times and seems to be unstable, disabling clipboard integration\n",
|
|
||||||
clipboardRestarts);
|
|
||||||
g_fClipboard = FALSE;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_fClipboard) {
|
|
||||||
sleep(WIN_CLIPBOARD_DELAY);
|
|
||||||
ErrorF("winClipboardProc - trying to restart clipboard thread \n");
|
|
||||||
/* Create the clipboard client thread */
|
|
||||||
if (!winInitClipboard()) {
|
|
||||||
ErrorF("winClipboardProc - winClipboardInit failed.\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
winDebug("winClipboardProc - winInitClipboard returned.\n");
|
|
||||||
/* Flag that clipboard client has been launched */
|
|
||||||
g_fClipboardLaunched = TRUE;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ErrorF("winClipboardProc - Clipboard disabled - Exit from server \n");
|
|
||||||
/* clipboard thread has exited, stop server as well */
|
|
||||||
raise(SIGTERM);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,9 +163,6 @@ winProcEstablishConnection(ClientPtr client)
|
||||||
ErrorF("winProcEstablishConnection - winInitClipboard returned.\n");
|
ErrorF("winProcEstablishConnection - winInitClipboard returned.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Flag that clipboard client has been launched */
|
|
||||||
g_fClipboardLaunched = TRUE;
|
|
||||||
|
|
||||||
return iReturn;
|
return iReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue