mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-06 21:58:57 -04:00
Optimized startup of RetroShare by removing two unnecessary calls to AuthGPGimpl::storeAllKeys.
Fixed small hangs of RetroShare by removing the core lock in RsServer::ConfigGetDataRates. Is that needed? git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4725 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
ef57cd44b3
commit
e150e31401
5 changed files with 54 additions and 23 deletions
|
@ -315,9 +315,24 @@ int AuthGPGimpl::GPGInit(const std::string &ownId)
|
||||||
}
|
}
|
||||||
|
|
||||||
mOwnGpgId = ownId;
|
mOwnGpgId = ownId;
|
||||||
}
|
|
||||||
|
|
||||||
storeAllKeys();
|
// clear old cert
|
||||||
|
gpgme_key_unref(mOwnGpgCert.key);
|
||||||
|
mOwnGpgCert = gpgcert();
|
||||||
|
|
||||||
|
// search own key
|
||||||
|
certmap::iterator it = mKeyList.find(mOwnGpgId);
|
||||||
|
if (it != mKeyList.end()) {
|
||||||
|
it->second.ownsign = true;
|
||||||
|
|
||||||
|
// store own key, grab a reference, so the key remains
|
||||||
|
gpgme_key_ref(it->second.key);
|
||||||
|
|
||||||
|
mOwnGpgCert = it->second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// already stored in AuthGPGimpl::InitAuth
|
||||||
|
// storeAllKeys();
|
||||||
|
|
||||||
int lvl = 0;
|
int lvl = 0;
|
||||||
|
|
||||||
|
@ -2319,7 +2334,8 @@ bool AuthGPGimpl::loadList(std::list<RsItem*>& load)
|
||||||
std::cerr << "AuthGPGimpl::loadList() Item Count: " << load.size() << std::endl;
|
std::cerr << "AuthGPGimpl::loadList() Item Count: " << load.size() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
storeAllKeys();
|
// already stored in AuthGPGimpl::InitAuth
|
||||||
|
// storeAllKeys();
|
||||||
|
|
||||||
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
|
||||||
/* load the list of accepted gpg keys */
|
/* load the list of accepted gpg keys */
|
||||||
|
|
|
@ -362,19 +362,35 @@ void p3ConfigMgr::loadConfig()
|
||||||
{
|
{
|
||||||
std::map<uint32_t, pqiConfig *>::iterator cit;
|
std::map<uint32_t, pqiConfig *>::iterator cit;
|
||||||
std::string dummyHash = "dummyHash";
|
std::string dummyHash = "dummyHash";
|
||||||
for (cit = configs.begin(); cit != configs.end(); cit++)
|
|
||||||
{
|
// step 0 -> load CONFIG_TYPE_AUTHGPG
|
||||||
|
// step 1 -> load all other
|
||||||
|
for (int step = 0; step < 2; ++step) {
|
||||||
|
for (cit = configs.begin(); cit != configs.end(); cit++)
|
||||||
|
{
|
||||||
|
if ((step == 0 && cit->first != CONFIG_TYPE_AUTHGPG) ||
|
||||||
|
(step == 1 && cit->first == CONFIG_TYPE_AUTHGPG)) {
|
||||||
|
// don't load configuration
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG
|
#ifdef CONFIG_DEBUG
|
||||||
std::cerr << "p3ConfigMgr::loadConfig() Element: ";
|
std::cerr << "p3ConfigMgr::loadConfig() Element: ";
|
||||||
std::cerr << cit->first <<"Dummy Hash: " << dummyHash;
|
std::cerr << cit->first <<"Dummy Hash: " << dummyHash;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cit->second->loadConfiguration(dummyHash);
|
cit->second->loadConfiguration(dummyHash);
|
||||||
|
|
||||||
/* force config to NOT CHANGED */
|
/* force config to NOT CHANGED */
|
||||||
cit->second->HasConfigChanged(0);
|
cit->second->HasConfigChanged(0);
|
||||||
cit->second->HasConfigChanged(1);
|
cit->second->HasConfigChanged(1);
|
||||||
|
|
||||||
|
if (step == 0) {
|
||||||
|
// CONFIG_TYPE_AUTHGPG loaded
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -1335,13 +1351,13 @@ bool pqiConfig::HasConfigChanged(uint16_t idx)
|
||||||
return ConfInd.Changed(idx);
|
return ConfInd.Changed(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pqiConfig::setFilename(std::string name)
|
void pqiConfig::setFilename(const std::string& name)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(cfgMtx); /***** LOCK STACK MUTEX ****/
|
RsStackMutex stack(cfgMtx); /***** LOCK STACK MUTEX ****/
|
||||||
filename = name;
|
filename = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pqiConfig::setHash(std::string h)
|
void pqiConfig::setHash(const std::string& h)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(cfgMtx); /***** LOCK STACK MUTEX ****/
|
RsStackMutex stack(cfgMtx); /***** LOCK STACK MUTEX ****/
|
||||||
hash = h;
|
hash = h;
|
||||||
|
|
|
@ -146,7 +146,7 @@ const std::string& Hash();
|
||||||
* Checks if configuration has changed
|
* Checks if configuration has changed
|
||||||
*/
|
*/
|
||||||
void IndicateConfigChanged();
|
void IndicateConfigChanged();
|
||||||
void setHash(std::string h);
|
void setHash(const std::string& h);
|
||||||
|
|
||||||
RsMutex cfgMtx;
|
RsMutex cfgMtx;
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ void setHash(std::string h);
|
||||||
/**
|
/**
|
||||||
* This sets the name of the pqi configuation file
|
* This sets the name of the pqi configuation file
|
||||||
*/
|
*/
|
||||||
void setFilename(std::string name);
|
void setFilename(const std::string& name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param an index for the Confind which contains list of configuarations that can be tracked
|
* @param an index for the Confind which contains list of configuarations that can be tracked
|
||||||
|
|
|
@ -73,17 +73,17 @@ int RsServer::ConfigSetDataRates( int totalDownload, int totalUpload ) /* in
|
||||||
int RsServer::ConfigGetDataRates( float &inKb, float &outKb ) /* in kbrates */
|
int RsServer::ConfigGetDataRates( float &inKb, float &outKb ) /* in kbrates */
|
||||||
{
|
{
|
||||||
/* fill the rsiface class */
|
/* fill the rsiface class */
|
||||||
RsIface &iface = getIface();
|
// RsIface &iface = getIface();
|
||||||
|
|
||||||
/* lock Mutexes */
|
/* lock Mutexes */
|
||||||
lockRsCore(); /* LOCK */
|
// lockRsCore(); /* LOCK */
|
||||||
iface.lockData(); /* LOCK */
|
// iface.lockData(); /* LOCK */
|
||||||
|
|
||||||
pqih -> getCurrentRates(inKb, outKb);
|
pqih -> getCurrentRates(inKb, outKb);
|
||||||
|
|
||||||
/* unlock Mutexes */
|
/* unlock Mutexes */
|
||||||
iface.unlockData(); /* UNLOCK */
|
// iface.unlockData(); /* UNLOCK */
|
||||||
unlockRsCore(); /* UNLOCK */
|
// unlockRsCore(); /* UNLOCK */
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2181,7 +2181,6 @@ int RsServer::StartupRetroShare()
|
||||||
//mConfigMgr->addConfiguration("ftserver.cfg", ftserver);
|
//mConfigMgr->addConfiguration("ftserver.cfg", ftserver);
|
||||||
//
|
//
|
||||||
mConfigMgr->addConfiguration("gpg_prefs.cfg", (AuthGPGimpl *) AuthGPG::getAuthGPG());
|
mConfigMgr->addConfiguration("gpg_prefs.cfg", (AuthGPGimpl *) AuthGPG::getAuthGPG());
|
||||||
mConfigMgr->loadConfiguration();
|
|
||||||
|
|
||||||
mConfigMgr->addConfiguration("peers.cfg", mPeerMgr);
|
mConfigMgr->addConfiguration("peers.cfg", mPeerMgr);
|
||||||
mConfigMgr->addConfiguration("general.cfg", mGeneralConfig);
|
mConfigMgr->addConfiguration("general.cfg", mGeneralConfig);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue