Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerhard Kreuzer2020-04-25 14:55:56 +0000
committerSravan Kumar Lakkimsetti2020-05-08 08:25:27 +0000
commit9316ada85778343925f78af8a5e123e750c57e8d (patch)
treee1b3a9faff2270d05ca8a51a5d4eecf42dc7d56b
parent33b6eb6b4a50da63af53291783d86936725873c5 (diff)
downloadrt.equinox.framework-9316ada85778343925f78af8a5e123e750c57e8d.tar.gz
rt.equinox.framework-9316ada85778343925f78af8a5e123e750c57e8d.tar.xz
rt.equinox.framework-9316ada85778343925f78af8a5e123e750c57e8d.zip
Bug 560428 - Mutex in the Windows launcher potentially gets not released
If a starting instance (with files to be opened on the command line) calls takeDownSplash() (through JNI) before the timer in the native launcher has fired for the first time, the associated Mutex never gets released and therefore this instance will never be found and reused. Pure E4 RCPs are likely to hit this one second time slot. Change-Id: I744b5d3741bf7bc6ece360527f3962dd2d9d5081 Signed-off-by: Gerhard Kreuzer <gerhard.kreuzer@siemens.com>
-rw-r--r--features/org.eclipse.equinox.executable.feature/library/win32/eclipseWin.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/features/org.eclipse.equinox.executable.feature/library/win32/eclipseWin.c b/features/org.eclipse.equinox.executable.feature/library/win32/eclipseWin.c
index 63dcc1307..c72a6f03b 100644
--- a/features/org.eclipse.equinox.executable.feature/library/win32/eclipseWin.c
+++ b/features/org.eclipse.equinox.executable.feature/library/win32/eclipseWin.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -12,6 +12,7 @@
* IBM Corporation - initial API and implementation
* Kevin Cornell (Rational Software Corporation)
* Holger Voormann - fix for bug 384950 (http://eclip.se/384950)
+ * Gerhard Kreuzer - fix for bug 560428
*******************************************************************************/
#include "eclipseOS.h"
@@ -41,7 +42,7 @@ _TCHAR* vmLibrary = _T("jvm.dll");
_TCHAR* shippedVMDir = _T("jre\\bin\\");
/* Define local variables for communicating with running eclipse instance. */
-static HANDLE mutex;
+static HANDLE mutex = 0;
static UINT findWindowTimeout = 1000;
static UINT_PTR findWindowTimerId = 97;
static UINT timerCount = 0;
@@ -135,6 +136,7 @@ static void CALLBACK findWindowProc(HWND hwnd, UINT message, UINT idTimer, DWORD
sendOpenFileMessage(window);
ReleaseMutex(mutex);
CloseHandle(mutex);
+ mutex = 0;
KillTimer(hwnd, findWindowTimerId);
return;
}
@@ -144,6 +146,7 @@ static void CALLBACK findWindowProc(HWND hwnd, UINT message, UINT idTimer, DWORD
KillTimer(hwnd, findWindowTimerId);
ReleaseMutex(mutex);
CloseHandle(mutex);
+ mutex = 0;
}
}
@@ -170,6 +173,7 @@ int reuseWorkbench(_TCHAR** filePath, int timeout) {
if (lock != WAIT_OBJECT_0) {
/* failed to get the lock before timeout, We won't be reusing an existing eclipse. */
CloseHandle(mutex);
+ mutex = 0;
return 0;
}
@@ -179,6 +183,7 @@ int reuseWorkbench(_TCHAR** filePath, int timeout) {
sendOpenFileMessage(window);
ReleaseMutex(mutex);
CloseHandle(mutex);
+ mutex = 0;
return 1; /* success! */
}
@@ -287,6 +292,19 @@ jlong getSplashHandle() {
void takeDownSplash() {
if(topWindow != NULL) {
+ if (mutex != NULL) {
+ KillTimer(topWindow, findWindowTimerId);
+
+ HWND window = findSWTMessageWindow();
+ if (window != NULL) {
+ sendOpenFileMessage(window);
+ }
+
+ ReleaseMutex(mutex);
+ CloseHandle(mutex);
+ mutex = 0;
+ }
+
DestroyWindow(topWindow);
dispatchMessages();
topWindow = 0;

Back to the top