fixed bug that would cause virtual peers list for outgoing files to never get cleanred up. Also improved cost of updating the status of virtual peers. Many thanks to Jolavillette for finding this out!

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6858 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2013-10-21 09:05:51 +00:00
parent 06f6f1949d
commit 6780ff2cff
3 changed files with 31 additions and 14 deletions

View File

@ -1806,9 +1806,6 @@ void ftController::statusChange(const std::list<pqipeer> &plist)
std::map<std::string, ftFileControl*>::iterator it;
std::list<pqipeer>::const_iterator pit;
std::list<pqipeer> vlist ;
mTurtle->getVirtualPeersList(vlist) ;
#ifdef CONTROL_DEBUG
std::cerr << "ftController::statusChange()";
std::cerr << std::endl;
@ -1856,6 +1853,11 @@ void ftController::statusChange(const std::list<pqipeer> &plist)
// Now also look at turtle virtual peers.
//
std::list<pqipeer> vlist ;
mTurtle->getSourceVirtualPeersList(it->first,vlist) ;
std::cerr << "vlist.size() = " << vlist.size() << std::endl;
for(pit = vlist.begin(); pit != vlist.end(); pit++)
{
#ifdef CONTROL_DEBUG

View File

@ -272,21 +272,31 @@ void p3turtle::locked_addDistantPeer(const TurtleFileHash&,TurtleTunnelId tid)
_local_tunnels[tid].vpid = TurtleVirtualPeerId(buff) ;
}
void p3turtle::getVirtualPeersList(std::list<pqipeer>& list)
void p3turtle::getSourceVirtualPeersList(const TurtleFileHash& hash,std::list<pqipeer>& list)
{
RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/
list.clear() ;
for(std::map<TurtleVirtualPeerId,TurtleTunnelId>::const_iterator it(_virtual_peers.begin());it!=_virtual_peers.end();++it)
{
pqipeer vp ;
vp.id = it->first ;
vp.name = "Virtual (distant) peer" ;
vp.state = RS_PEER_S_CONNECTED ;
vp.actions = RS_PEER_CONNECTED ;
list.push_back(vp) ;
}
std::map<TurtleFileHash,TurtleHashInfo>::const_iterator it = _incoming_file_hashes.find(hash) ;
if(it != _incoming_file_hashes.end())
for(uint32_t i=0;i<it->second.tunnels.size();++i)
{
std::map<TurtleTunnelId,TurtleTunnel>::const_iterator it2 = _local_tunnels.find( it->second.tunnels[i] ) ;
if(it2 != _local_tunnels.end())
{
pqipeer vp ;
vp.id = it2->second.vpid ;
vp.name = "Virtual (distant) peer" ;
vp.state = RS_PEER_S_CONNECTED ;
vp.actions = RS_PEER_CONNECTED ;
list.push_back(vp) ;
}
else
std::cerr << "(EE) getSourceVirtualPeersList(): no tunnels for incoming file hash " << hash << ": weird!"<< std::endl;
}
}
// This method handles digging new tunnels as needed.
@ -581,6 +591,11 @@ void p3turtle::locked_closeTunnel(TurtleTunnelId tid,std::vector<std::pair<RsTur
sources_to_remove.push_back(std::pair<RsTurtleClientService*,std::pair<TurtleFileHash,TurtleVirtualPeerId> >(itHash->second,hash_vpid)) ;
_outgoing_file_hashes.erase(itHash) ;
// Also remove the associated virtual peer
//
if(_virtual_peers.find(vpid) != _virtual_peers.end())
_virtual_peers.erase(_virtual_peers.find(vpid)) ;
}
}

View File

@ -305,7 +305,7 @@ class p3turtle: public p3Service, public RsTurtle, public p3Config
std::string getTurtlePeerId(TurtleTunnelId tid) const ;
/// returns the list of virtual peers for all tunnels.
void getVirtualPeersList(std::list<pqipeer>& list) ;
void getSourceVirtualPeersList(const TurtleFileHash& hash,std::list<pqipeer>& list) ;
/// Send a data request into the correct tunnel for the given file hash
void sendTurtleData(const std::string& virtual_peer_id, RsTurtleGenericTunnelItem *item) ;