mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-21 23:40:26 -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
|
@ -91,7 +91,19 @@ int main(int argc, char **argv)
|
|||
|
||||
/* Key + Certificate are loaded into libretroshare */
|
||||
|
||||
RsInit::LoadCertificates(false);
|
||||
int retVal = RsInit::LockAndLoadCertificates(false);
|
||||
switch(retVal)
|
||||
{
|
||||
case 0: break;
|
||||
case 1: std::cerr << "Error: another instance of retroshare is already using this profile" << std::endl;
|
||||
return 1;
|
||||
case 2: std::cerr << "An unexpected error occurred while locking the profile" << std::endl;
|
||||
return 1;
|
||||
case 3: std::cerr << "An error occurred while login with the profile" << std::endl;
|
||||
return 1;
|
||||
default: std::cerr << "Main: Unexpected switch value " << retVal << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Start-up libretroshare server threads */
|
||||
rsServer -> StartupRetroShare();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue