p3StatusService::getStatusQueue

- memory leak -> "RsItem* item" was not freed, when "dynamic_cast<RsStatusItem*>" failed
- optimized return of std::list as parameter and not as return. return will copy the list and its not necessary

p3StatusService::getStatus
- memory leak -> items in "std::list<RsStatusItem* > status_items" was not freed
- potential crash, when receiving a status for an unknown peer

p3Peers::getPeerDetails
- optimized - call to "AuthSSL::getAuthSSL()->OwnId()" only once
- optimized - add ip addresses directly to "d.ipAddressList"

PeersDialog::insertPeers
- fixed possible crash, when ssl child has disappeared and was removed from tree, there was a missing continue

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3125 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-06-13 12:26:23 +00:00
parent 61f2c14663
commit 0d1eaba890
5 changed files with 53 additions and 51 deletions

View file

@ -276,8 +276,9 @@ bool p3Peers::getPeerDetails(std::string id, RsPeerDetails &d)
std::cerr << "p3Peers::getPeerDetails() called for id : " << id << std::endl;
#endif
//first, check if it's a gpg or a ssl id.
std::string sOwnId = AuthSSL::getAuthSSL()->OwnId();
peerConnectState pcs;
if (id != AuthSSL::getAuthSSL()->OwnId() && !mConnMgr->getFriendNetStatus(id, pcs)) {
if (id != sOwnId && !mConnMgr->getFriendNetStatus(id, pcs)) {
//assume is not SSL, because every ssl_id has got a friend correspondance in mConnMgr
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getPeerDetails() got a gpg id and is returning GPG details only for id : " << id << std::endl;
@ -289,7 +290,7 @@ bool p3Peers::getPeerDetails(std::string id, RsPeerDetails &d)
std::cerr << "p3Peers::getPeerDetails() got a SSL id and is returning SSL and GPG details for id : " << id << std::endl;
#endif
if (id == AuthSSL::getAuthSSL()->OwnId()) {
if (id == sOwnId) {
mConnMgr->getOwnNetStatus(pcs);
pcs.gpg_id = AuthGPG::getAuthGPG()->getGPGOwnId();
}
@ -322,14 +323,13 @@ bool p3Peers::getPeerDetails(std::string id, RsPeerDetails &d)
d.dyndns = pcs.dyndns;
d.lastConnect = pcs.lastcontact;
d.connectPeriod = 0;
std::list<std::string> ipAddressList;
std::list<IpAddressTimed> pcsList = pcs.getIpAddressList();
d.ipAddressList.clear();
for (std::list<IpAddressTimed>::iterator ipListIt = pcsList.begin(); ipListIt!=(pcsList.end()); ipListIt++) {
std::ostringstream toto;
toto << ntohs(ipListIt->ipAddr.sin_port) << " " << (time(NULL) - ipListIt->seenTime) << " sec";
ipAddressList.push_back(std::string(inet_ntoa(ipListIt->ipAddr.sin_addr)) + ":" + toto.str());
d.ipAddressList.push_back(std::string(inet_ntoa(ipListIt->ipAddr.sin_addr)) + ":" + toto.str());
}
d.ipAddressList = ipAddressList;
/* Translate */