removed some unnecessary calls to IndicateConfigChanged() that caused saving some config files too often

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5.5@7151 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2014-02-26 19:42:27 +00:00
parent b105390563
commit 79be0e0452
3 changed files with 41 additions and 14 deletions

View file

@ -1327,7 +1327,9 @@ bool ftController::FileRequest(const std::string& fname, const std::string& has
mDownloads[hash] = ftfc; mDownloads[hash] = ftfc;
} }
if(!(flags & RS_FILE_REQ_CACHE))
IndicateConfigChanged(); /* completed transfer -> save */ IndicateConfigChanged(); /* completed transfer -> save */
return true; return true;
} }

View file

@ -620,7 +620,6 @@ bool p3PeerMgrIMPL::removeFriend(const std::string &id, bool removePgpId)
mOthersList[id] = peer; mOthersList[id] = peer;
mStatusChanged = true; mStatusChanged = true;
success = true; success = true;
} }
} }
@ -774,6 +773,11 @@ bool p3PeerMgrIMPL::addNeighbour(std::string id)
* as it doesn't call back to there. * as it doesn't call back to there.
*/ */
static bool operator!=(const struct sockaddr_in& a1,const struct sockaddr_in& a2)
{
return a1.sin_addr.s_addr != a2.sin_addr.s_addr || a1.sin_port != a2.sin_port ;
}
bool p3PeerMgrIMPL::UpdateOwnAddress(const struct sockaddr_in &localAddr, const struct sockaddr_in &extAddr) bool p3PeerMgrIMPL::UpdateOwnAddress(const struct sockaddr_in &localAddr, const struct sockaddr_in &extAddr)
{ {
std::cerr << "p3PeerMgrIMPL::UpdateOwnAddress("; std::cerr << "p3PeerMgrIMPL::UpdateOwnAddress(";
@ -781,17 +785,21 @@ bool p3PeerMgrIMPL::UpdateOwnAddress(const struct sockaddr_in &localAddr, const
std::cerr << ", "; std::cerr << ", ";
std::cerr << rs_inet_ntoa(extAddr.sin_addr) << ":" << htons(extAddr.sin_port); std::cerr << rs_inet_ntoa(extAddr.sin_addr) << ":" << htons(extAddr.sin_port);
std::cerr << ")" << std::endl; std::cerr << ")" << std::endl;
bool changed = false ;
{ {
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
//update ip address list //update ip address list
pqiIpAddress ipAddressTimed; pqiIpAddress ipAddressTimed;
if(ipAddressTimed.mAddr != localAddr) changed = true ;
ipAddressTimed.mAddr = localAddr; ipAddressTimed.mAddr = localAddr;
ipAddressTimed.mSeenTime = time(NULL); ipAddressTimed.mSeenTime = time(NULL);
ipAddressTimed.mSrc = 0 ; ipAddressTimed.mSrc = 0 ;
mOwnState.ipAddrs.updateLocalAddrs(ipAddressTimed); mOwnState.ipAddrs.updateLocalAddrs(ipAddressTimed);
if(mOwnState.localaddr != localAddr) changed = true ;
mOwnState.localaddr = localAddr; mOwnState.localaddr = localAddr;
} }
@ -801,6 +809,9 @@ bool p3PeerMgrIMPL::UpdateOwnAddress(const struct sockaddr_in &localAddr, const
//update ip address list //update ip address list
pqiIpAddress ipAddressTimed; pqiIpAddress ipAddressTimed;
if(ipAddressTimed.mAddr != extAddr) changed = true ;
ipAddressTimed.mAddr = extAddr; ipAddressTimed.mAddr = extAddr;
ipAddressTimed.mSeenTime = time(NULL); ipAddressTimed.mSeenTime = time(NULL);
ipAddressTimed.mSrc = 0 ; ipAddressTimed.mSrc = 0 ;
@ -826,6 +837,8 @@ bool p3PeerMgrIMPL::UpdateOwnAddress(const struct sockaddr_in &localAddr, const
} }
else if (mOwnState.netMode & RS_NET_MODE_EXT) else if (mOwnState.netMode & RS_NET_MODE_EXT)
{ {
if(mOwnState.serveraddr.sin_addr.s_addr != extAddr.sin_addr.s_addr) changed = true ;
mOwnState.serveraddr.sin_addr.s_addr = extAddr.sin_addr.s_addr; mOwnState.serveraddr.sin_addr.s_addr = extAddr.sin_addr.s_addr;
std::cerr << "p3PeerMgrIMPL::UpdateOwnAddress() Disabling Update of Server Port "; std::cerr << "p3PeerMgrIMPL::UpdateOwnAddress() Disabling Update of Server Port ";
std::cerr << " as MANUAL FORWARD Mode"; std::cerr << " as MANUAL FORWARD Mode";
@ -837,11 +850,15 @@ bool p3PeerMgrIMPL::UpdateOwnAddress(const struct sockaddr_in &localAddr, const
} }
else else
{ {
if(mOwnState.serveraddr != extAddr) changed = true ;
mOwnState.serveraddr = extAddr; mOwnState.serveraddr = extAddr;
} }
} }
if(changed)
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
mLinkMgr->setLocalAddress(localAddr); mLinkMgr->setLocalAddress(localAddr);
return true; return true;
@ -1039,7 +1056,6 @@ bool p3PeerMgrIMPL::updateAddressList(const std::string& id, const pqiIpAddrS
} }
/* "it" points to peer */ /* "it" points to peer */
it->second.ipAddrs.updateAddrs(addrs);
#ifdef PEER_DEBUG #ifdef PEER_DEBUG
std::cerr << "p3PeerMgrIMPL::setLocalAddress() Updated Address for: " << id; std::cerr << "p3PeerMgrIMPL::setLocalAddress() Updated Address for: " << id;
std::cerr << std::endl; std::cerr << std::endl;
@ -1047,6 +1063,7 @@ bool p3PeerMgrIMPL::updateAddressList(const std::string& id, const pqiIpAddrS
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
if(it->second.ipAddrs.updateAddrs(addrs))
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
return true; return true;
@ -1058,6 +1075,7 @@ bool p3PeerMgrIMPL::updateCurrentAddress(const std::string& id, const pqiIpAd
#ifdef PEER_DEBUG #ifdef PEER_DEBUG
std::cerr << "p3PeerMgrIMPL::updateCurrentAddress() called for id : " << id << std::endl; std::cerr << "p3PeerMgrIMPL::updateCurrentAddress() called for id : " << id << std::endl;
#endif #endif
bool changed = false ;
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
@ -1076,12 +1094,21 @@ bool p3PeerMgrIMPL::updateCurrentAddress(const std::string& id, const pqiIpAd
if (isPrivateNet(&(addr.mAddr.sin_addr))) if (isPrivateNet(&(addr.mAddr.sin_addr)))
{ {
it->second.ipAddrs.updateLocalAddrs(addr); if(it->second.ipAddrs.updateLocalAddrs(addr))
changed = true ;
if(it->second.localaddr != addr.mAddr) changed = true ;
it->second.localaddr = addr.mAddr; it->second.localaddr = addr.mAddr;
} }
else else
{ {
it->second.ipAddrs.updateExtAddrs(addr); if(it->second.ipAddrs.updateExtAddrs(addr))
changed = true ;
if(it->second.serveraddr != addr.mAddr)
changed = true ;
it->second.serveraddr = addr.mAddr; it->second.serveraddr = addr.mAddr;
} }
@ -1092,6 +1119,7 @@ bool p3PeerMgrIMPL::updateCurrentAddress(const std::string& id, const pqiIpAd
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
if(changed)
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
return true; return true;
@ -1922,8 +1950,10 @@ void p3PeerMgrIMPL::setServicePermissionFlags(const std::string& pgp_id, const S
return ; return ;
} }
mFriendsPermissionFlags[pgp_id] = flags ; if(mFriendsPermissionFlags[pgp_id] != flags)
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
mFriendsPermissionFlags[pgp_id] = flags ;
} }
/********************************************************************** /**********************************************************************

View file

@ -431,11 +431,8 @@ void p3turtle::autoWash()
_incoming_file_hashes.erase(it) ; _incoming_file_hashes.erase(it) ;
} }
if(!_hashes_to_remove.empty()) if(!_hashes_to_remove.empty())
{
IndicateConfigChanged() ; // initiates saving of handled hashes.
_hashes_to_remove.clear() ; _hashes_to_remove.clear() ;
} }
}
// look for tunnels and stored temporary info that have not been used for a while. // look for tunnels and stored temporary info that have not been used for a while.
@ -1871,8 +1868,6 @@ void p3turtle::monitorTunnels(const std::string& hash,RsTurtleClientService *cli
_incoming_file_hashes[hash].last_digg_time = RSRandom::random_u32()%10 ; _incoming_file_hashes[hash].last_digg_time = RSRandom::random_u32()%10 ;
_incoming_file_hashes[hash].service = client_service ; _incoming_file_hashes[hash].service = client_service ;
} }
IndicateConfigChanged() ; // initiates saving of handled hashes.
} }
void p3turtle::returnSearchResult(RsTurtleSearchResultItem *item) void p3turtle::returnSearchResult(RsTurtleSearchResultItem *item)