diff options
author | Jon TURNEY <jon.turney@dronecode.org.uk> | 2011-03-03 18:11:22 +0000 |
---|---|---|
committer | Jon TURNEY <jon.turney@dronecode.org.uk> | 2012-03-09 22:15:10 +0000 |
commit | cae2166179141d168c6af70167ff6e89786a9f6b (patch) | |
tree | 2107284673ef37924cfe77c570bccfca576a894f | |
parent | 4c60d0ef359952f15d14bc36e8f57eda3afd36e0 (diff) |
Fix the long-broken -silent-dup-error option
This is a horrible hack and is probably not suitable for pushing upstream.
Signed-off-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
-rw-r--r-- | hw/xwin/InitOutput.c | 86 | ||||
-rw-r--r-- | hw/xwin/winerror.c | 16 |
2 files changed, 16 insertions, 86 deletions
diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c index 4a601b222..ab6557b7b 100644 --- a/hw/xwin/InitOutput.c +++ b/hw/xwin/InitOutput.c @@ -84,8 +84,6 @@ void OsVendorVErrorF (const char *pszFormat, va_list va_args); #endif -static Bool -winCheckDisplayNumber (void); void winLogCommandLine (int argc, char *argv[]); @@ -933,15 +931,6 @@ InitOutput (ScreenInfo *screenInfo, int argc, char *argv[]) "Exiting.\n"); } - /* Check for duplicate invocation on same display number.*/ - if (serverGeneration == 1 && !winCheckDisplayNumber ()) - { - if (g_fSilentDupError) - g_fSilentFatalError = TRUE; - FatalError ("InitOutput - Duplicate invocation on display " - "number: %s. Exiting.\n", display); - } - #ifdef XWIN_XF86CONFIG /* Try to read the xorg.conf-style configuration file */ if (!winReadConfigfile ()) @@ -1009,78 +998,3 @@ InitOutput (ScreenInfo *screenInfo, int argc, char *argv[]) winDebug ("InitOutput - Returning.\n"); #endif } - - -/* - * winCheckDisplayNumber - Check if another instance of Cygwin/X is - * already running on the same display number. If no one exists, - * make a mutex to prevent new instances from running on the same display. - * - * return FALSE if the display number is already used. - */ - -static Bool -winCheckDisplayNumber (void) -{ - int nDisp; - HANDLE mutex; - char name[MAX_PATH]; - char * pszPrefix = '\0'; - OSVERSIONINFO osvi = {0}; - - /* Check display range */ - nDisp = atoi (display); - if (nDisp < 0 || nDisp > 65535) - { - ErrorF ("winCheckDisplayNumber - Bad display number: %d\n", nDisp); - return FALSE; - } - - /* Set first character of mutex name to null */ - name[0] = '\0'; - - /* Get operating system version information */ - osvi.dwOSVersionInfoSize = sizeof (osvi); - GetVersionEx (&osvi); - - /* Want a mutex shared among all terminals on NT > 4.0 */ - if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT - && osvi.dwMajorVersion >= 5) - { - pszPrefix = "Global\\"; - } - - /* Setup Cygwin/X specific part of name */ - snprintf (name, sizeof(name), "%sCYGWINX_DISPLAY:%d", pszPrefix, nDisp); - - /* Windows automatically releases the mutex when this process exits */ - mutex = CreateMutex (NULL, FALSE, name); - if (!mutex) - { - LPVOID lpMsgBuf; - - /* Display a fancy error message */ - FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError (), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR) &lpMsgBuf, - 0, NULL); - ErrorF ("winCheckDisplayNumber - CreateMutex failed: %s\n", - (LPSTR)lpMsgBuf); - LocalFree (lpMsgBuf); - - return FALSE; - } - if (GetLastError () == ERROR_ALREADY_EXISTS) - { - ErrorF ("winCheckDisplayNumber - " - PROJECT_NAME " is already running on display %d\n", - nDisp); - return FALSE; - } - - return TRUE; -} diff --git a/hw/xwin/winerror.c b/hw/xwin/winerror.c index 0440d13ff..5c54e9f23 100644 --- a/hw/xwin/winerror.c +++ b/hw/xwin/winerror.c @@ -52,6 +52,22 @@ OsVendorVErrorF (const char *pszFormat, va_list va_args) pthread_mutex_lock (&s_pmPrinting); #endif + /* If we want to silence it, + * detect if we are going to abort due to duplication error */ + if (g_fSilentDupError) + { + if ((strcmp(pszFormat, + "InitOutput - Duplicate invocation on display " + "number: %s. Exiting.\n") == 0) + || (strcmp(pszFormat, + "Server is already active for display %s\n%s %s\n%s\n") == 0) + || (strcmp(pszFormat, + "MakeAllCOTSServerListeners: server already running\n") == 0)) + { + g_fSilentFatalError = TRUE; + } + } + /* Print the error message to a log file, could be stderr */ LogVWrite (0, pszFormat, va_args); |