--- a/src/jdk.jpackage/share/native/libapplauncher/WindowsPlatform.cpp Mon Jan 07 16:43:30 2019 -0500
+++ b/src/jdk.jpackage/share/native/libapplauncher/WindowsPlatform.cpp Tue Jan 08 07:37:14 2019 -0500
@@ -292,114 +292,6 @@
return TRUE;
}
-void WindowsPlatform::reactivateAnotherInstance() {
- if (singleInstanceProcessId == 0) {
- printf("Unable to reactivate another instance, PID is undefined");
- return;
- }
- EnumWindows(&enumWindows, (LPARAM)singleInstanceProcessId);
-}
-
-// returns true if another instance is already running.
-// if false, we need to continue regular launch.
-bool WindowsPlatform::CheckForSingleInstance(TString name) {
- if (SingleInstance::getInstance(name)->IsAnotherInstanceRunning()) {
- // read PID
- DWORD pid = SingleInstance::getInstance(name)->readPid();
- if (pid != 0) {
- singleInstanceProcessId = pid;
- return true;
- }
- } else {
- // it is the first intance
- // write pid and continue regular launch
- SingleInstance::getInstance(name)->writePid(GetCurrentProcessId());
- }
- return false;
-}
-
-SingleInstance::SingleInstance(TString& name_): BUF_SIZE(256), _name(name_),
- _hMapFile(NULL), _pBuf(NULL) {
- _mutex = CreateMutex(NULL, TRUE, name_.data());
- _lastError = GetLastError();
- _sharedMemoryName = _T("Local\\jpackage-") + _name;
-}
-
-SingleInstance::~SingleInstance() {
- if (_pBuf != NULL) {
- UnmapViewOfFile(_pBuf);
- _pBuf = NULL;
- }
-
- if (_hMapFile != NULL) {
- CloseHandle(_hMapFile);
- _hMapFile = NULL;
- }
-
- if (_mutex != NULL) {
- CloseHandle(_mutex);
- _mutex = NULL;
- }
-}
-
-bool SingleInstance::writePid(DWORD pid) {
- _hMapFile = CreateFileMapping(
- INVALID_HANDLE_VALUE,
- NULL,
- PAGE_READWRITE,
- 0,
- BUF_SIZE,
- _sharedMemoryName.data());
-
- if (_hMapFile == NULL) {
- return false;
- }
-
- _pBuf = (LPTSTR) MapViewOfFile(_hMapFile,
- FILE_MAP_ALL_ACCESS,
- 0,
- 0,
- BUF_SIZE);
-
- if (_pBuf == NULL) {
- CloseHandle(_hMapFile);
- _hMapFile = NULL;
- return false;
- }
-
- CopyMemory((PVOID)_pBuf, &pid, sizeof(DWORD));
-
- return true;
-}
-
-DWORD SingleInstance::readPid() {
- _hMapFile = OpenFileMapping(
- FILE_MAP_ALL_ACCESS,
- FALSE,
- _sharedMemoryName.data());
-
- if (_hMapFile == NULL) {
- return 0;
- }
-
- _pBuf = (LPTSTR) MapViewOfFile(_hMapFile,
- FILE_MAP_ALL_ACCESS,
- 0,
- 0,
- BUF_SIZE);
-
- if (_pBuf == NULL) {
- CloseHandle(_hMapFile);
- _hMapFile = NULL;
- return 0;
- }
-
- DWORD pid = 0;
- CopyMemory(&pid, (PVOID)_pBuf, sizeof(DWORD));
-
- return pid;
-}
-
TPlatformNumber WindowsPlatform::GetMemorySize() {
SYSTEM_INFO si;
GetSystemInfo(&si);