Bug 1553781: When the remote service finds an instance to remote to it doesn't clean up the startup lock. r=glandium

This fixes the issue in a few redundant ways:
* nsProfileLock is made to properly clean itself up when destroyed.
* nsRemoteService makes sure the unlock when destroyed.
* nsAppRunner unlocks when a remote client has been found.

Differential Revision: https://phabricator.services.mozilla.com/D32360

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dave Townsend 2019-05-30 17:53:36 +00:00
Родитель 8a3753f034
Коммит cf20f54068
3 изменённых файлов: 21 добавлений и 6 удалений

Просмотреть файл

@ -77,10 +77,10 @@ void nsRemoteService::LockStartup() {
}
void nsRemoteService::UnlockStartup() {
mRemoteLock.Unlock();
mRemoteLock.Cleanup();
if (mRemoteLockDir) {
mRemoteLock.Unlock();
mRemoteLock.Cleanup();
mRemoteLockDir->Remove(false);
mRemoteLockDir = nullptr;
}
@ -174,7 +174,10 @@ void nsRemoteService::StartupServer() {
void nsRemoteService::ShutdownServer() { mRemoteServer = nullptr; }
nsRemoteService::~nsRemoteService() { ShutdownServer(); }
nsRemoteService::~nsRemoteService() {
UnlockStartup();
ShutdownServer();
}
NS_IMETHODIMP
nsRemoteService::Observe(nsISupports* aSubject, const char* aTopic,

Просмотреть файл

@ -84,7 +84,11 @@ nsProfileLock& nsProfileLock::operator=(nsProfileLock& rhs) {
return *this;
}
nsProfileLock::~nsProfileLock() { Unlock(); }
nsProfileLock::~nsProfileLock() {
Unlock();
// Note that we don't clean up by default here so on next startup we know when
// the profile was last used based on the modification time of the lock file.
}
#if defined(XP_UNIX)
@ -566,8 +570,14 @@ nsresult nsProfileLock::Unlock(bool aFatalSignal) {
}
nsresult nsProfileLock::Cleanup() {
if (mHaveLock) {
return NS_ERROR_FILE_IS_LOCKED;
}
if (mLockFile) {
return mLockFile->Remove(false);
nsresult rv = mLockFile->Remove(false);
NS_ENSURE_SUCCESS(rv, rv);
mLockFile = nullptr;
}
return NS_OK;

Просмотреть файл

@ -4000,9 +4000,11 @@ int XREMain::XRE_mainStartup(bool* aExitFlag) {
RemoteResult rr = mRemoteService->StartClient(desktopStartupIDPtr);
if (rr == REMOTE_FOUND) {
*aExitFlag = true;
mRemoteService->UnlockStartup();
return 0;
}
if (rr == REMOTE_ARG_BAD) {
mRemoteService->UnlockStartup();
return 1;
}
}