mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-11 15:50:38 -04:00
Prevent multiple instances from running on Unix systems.
Every call to RsInit::LoadCertificates() now creates a file: ~/.retroshare/xxxxxxxxxxxxxxxxxxxx/lock which is then bound to a system lock (fcntl F_SETLK). If the lock request fails, it means another instance is already running with the same profile. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3241 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
840f077826
commit
fe46d7618a
7 changed files with 221 additions and 47 deletions
|
@ -320,19 +320,27 @@ void GenCertDialog::checkChanged(int i)
|
|||
|
||||
void GenCertDialog::loadCertificates()
|
||||
{
|
||||
bool autoSave = false;
|
||||
/* Final stage of loading */
|
||||
if (RsInit::LoadCertificates(autoSave))
|
||||
int retVal = RsInit::LockAndLoadCertificates(false);
|
||||
switch(retVal)
|
||||
{
|
||||
close();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* some error msg */
|
||||
QMessageBox::warning ( NULL,
|
||||
"Generate ID Failure",
|
||||
"Failed to Load your new Certificate!",
|
||||
QMessageBox::Ok);
|
||||
case 0: close();
|
||||
break;
|
||||
case 1: QMessageBox::warning( this,
|
||||
tr("Multiple instances"),
|
||||
tr("Another RetroShare using the same profile is "
|
||||
"already running on your system. Please close "
|
||||
"that instance first") );
|
||||
break;
|
||||
case 2: QMessageBox::warning( this,
|
||||
tr("Multiple instances"),
|
||||
tr("An unexpected error occurred when Retroshare"
|
||||
"tried to acquire the single instance lock") );
|
||||
break;
|
||||
case 3: QMessageBox::warning( this,
|
||||
tr("Generate ID Failure"),
|
||||
tr("Failed to Load your new Certificate!") );
|
||||
break;
|
||||
default: std::cerr << "StartDialog::loadCertificates() unexpected switch value " << retVal << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue