mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Send stack for outgoing peer informations on connect of a peer.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3538 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
0ffaf67ae0
commit
55a45dacd3
@ -119,7 +119,42 @@ int p3disc::tick()
|
|||||||
sendHeartbeat(*pit);
|
sendHeartbeat(*pit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string destId;
|
||||||
|
std::string srcId;
|
||||||
|
|
||||||
|
{
|
||||||
|
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
|
while (!sendIdList.empty()) {
|
||||||
|
std::map<std::string, std::list<std::string> >::iterator sendIdIt = sendIdList.begin();
|
||||||
|
|
||||||
|
if (!sendIdIt->second.empty() && mConnMgr->isOnline(sendIdIt->first)) {
|
||||||
|
std::string gpgId = sendIdIt->second.front();
|
||||||
|
sendIdIt->second.pop_front();
|
||||||
|
|
||||||
|
destId = sendIdIt->first;
|
||||||
|
srcId = gpgId;
|
||||||
|
|
||||||
|
/* send only one per tick */
|
||||||
|
#ifdef P3DISC_DEBUG
|
||||||
|
int count = 0;
|
||||||
|
for (sendIdIt = sendIdList.begin(); sendIdIt != sendIdList.end(); sendIdIt++) {
|
||||||
|
count += sendIdIt->second.size();
|
||||||
|
}
|
||||||
|
std::cerr << "p3disc::tick() Count of gpg id's " << count << std::endl;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
/* peer is not online anymore ... try next */
|
||||||
|
sendIdList.erase(sendIdIt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!destId.empty() && !srcId.empty()) {
|
||||||
|
sendPeerDetails(destId, srcId);
|
||||||
|
}
|
||||||
|
|
||||||
return handleIncoming();
|
return handleIncoming();
|
||||||
}
|
}
|
||||||
@ -199,11 +234,13 @@ int p3disc::handleIncoming()
|
|||||||
|
|
||||||
// process one disc item
|
// process one disc item
|
||||||
if (!discReplyList.empty()) {
|
if (!discReplyList.empty()) {
|
||||||
std::cerr << "p3disc::handleIncoming() Count of disc items " << discReplyList.size() << std::endl;
|
|
||||||
RsDiscReply *dri = discReplyList.front();
|
RsDiscReply *dri = discReplyList.front();
|
||||||
discReplyList.pop_front();
|
discReplyList.pop_front();
|
||||||
recvPeerDetails(dri);
|
recvPeerDetails(dri);
|
||||||
nhandled++;
|
nhandled++;
|
||||||
|
#ifdef P3DISC_DEBUG
|
||||||
|
std::cerr << "p3disc::handleIncoming() Count of disc items " << discReplyList.size() << std::endl;
|
||||||
|
#endif
|
||||||
delete dri;
|
delete dri;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,7 +314,7 @@ void p3disc::sendAllInfoToJustConnectedPeer(std::string id)
|
|||||||
|
|
||||||
std::list<std::string> friendIds;
|
std::list<std::string> friendIds;
|
||||||
std::list<std::string>::iterator friendIdsIt;
|
std::list<std::string>::iterator friendIdsIt;
|
||||||
std::set<std::string> gpgIds;;
|
std::set<std::string> gpgIds;
|
||||||
|
|
||||||
rsPeers->getFriendList(friendIds);
|
rsPeers->getFriendList(friendIds);
|
||||||
|
|
||||||
@ -298,11 +335,20 @@ void p3disc::sendAllInfoToJustConnectedPeer(std::string id)
|
|||||||
//add own info
|
//add own info
|
||||||
gpgIds.insert(rsPeers->getGPGOwnId());
|
gpgIds.insert(rsPeers->getGPGOwnId());
|
||||||
|
|
||||||
//send details for each gpg Ids
|
{
|
||||||
std::set<std::string>::iterator gpgIdsIt;
|
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
||||||
for (gpgIdsIt = gpgIds.begin(); gpgIdsIt != gpgIds.end(); gpgIdsIt++) {
|
|
||||||
sendPeerDetails(id, *gpgIdsIt);
|
/* append gpg id's to the sending list for the id */
|
||||||
}
|
|
||||||
|
std::list<std::string> &idList = sendIdList[id];
|
||||||
|
|
||||||
|
std::set<std::string>::iterator gpgIdsIt;
|
||||||
|
for (gpgIdsIt = gpgIds.begin(); gpgIdsIt != gpgIds.end(); gpgIdsIt++) {
|
||||||
|
if (std::find(idList.begin(), idList.end(), *gpgIdsIt) == idList.end()) {
|
||||||
|
idList.push_back(*gpgIdsIt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef P3DISC_DEBUG
|
#ifdef P3DISC_DEBUG
|
||||||
std::cerr << "p3disc::sendAllInfoToJustConnectedPeer() finished." << std::endl;
|
std::cerr << "p3disc::sendAllInfoToJustConnectedPeer() finished." << std::endl;
|
||||||
@ -318,14 +364,22 @@ void p3disc::sendJustConnectedPeerInfoToAllPeer(std::string connectedPeerId)
|
|||||||
#endif
|
#endif
|
||||||
std::string gpg_connectedPeerId = rsPeers->getGPGId(connectedPeerId);
|
std::string gpg_connectedPeerId = rsPeers->getGPGId(connectedPeerId);
|
||||||
std::list<std::string> onlineIds;
|
std::list<std::string> onlineIds;
|
||||||
std::list<std::string>::iterator onlineIdsIt;
|
|
||||||
|
|
||||||
rsPeers->getOnlineList(onlineIds);
|
rsPeers->getOnlineList(onlineIds);
|
||||||
|
|
||||||
/* send them a list of all friend's details */
|
{
|
||||||
for(onlineIdsIt = onlineIds.begin(); onlineIdsIt != onlineIds.end(); onlineIdsIt++) {
|
RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/
|
||||||
sendPeerDetails(*onlineIdsIt, gpg_connectedPeerId);
|
|
||||||
}
|
/* append gpg id's of all friend's to the sending list */
|
||||||
|
|
||||||
|
std::list<std::string>::iterator onlineIdsIt;
|
||||||
|
for (onlineIdsIt = onlineIds.begin(); onlineIdsIt != onlineIds.end(); onlineIdsIt++) {
|
||||||
|
std::list<std::string> &idList = sendIdList[*onlineIdsIt];
|
||||||
|
if (std::find(idList.begin(), idList.end(), gpg_connectedPeerId) == idList.end()) {
|
||||||
|
idList.push_back(gpg_connectedPeerId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (dest (to), source (cert)) */
|
/* (dest (to), source (cert)) */
|
||||||
|
@ -146,6 +146,7 @@ int idServers();
|
|||||||
std::map<std::string, autoneighbour> neighbours;
|
std::map<std::string, autoneighbour> neighbours;
|
||||||
std::map<std::string, std::string> versions;
|
std::map<std::string, std::string> versions;
|
||||||
|
|
||||||
|
std::map<std::string, std::list<std::string> > sendIdList;
|
||||||
std::list<RsDiscReply*> discReplyList;
|
std::list<RsDiscReply*> discReplyList;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user