mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-10 01:55:19 -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
|
@ -152,18 +152,27 @@ void StartDialog::loadPerson()
|
|||
void StartDialog::loadCertificates()
|
||||
{
|
||||
/* Final stage of loading */
|
||||
|
||||
if (RsInit::LoadCertificates(ui.autologin_checkbox->isChecked()))
|
||||
int retVal = RsInit::LockAndLoadCertificates(ui.autologin_checkbox->isChecked());
|
||||
switch(retVal)
|
||||
{
|
||||
close();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* some error msg */
|
||||
QMessageBox::warning ( this,
|
||||
tr("Login Failure"),
|
||||
tr("Maybe password is wrong"),
|
||||
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, or choose another profile") );
|
||||
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("Login Failure"),
|
||||
tr("Maybe password is wrong") );
|
||||
break;
|
||||
default: std::cerr << "StartDialog::loadCertificates() unexpected switch value " << retVal << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue