mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed a few bugs related to previous commit
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-GenericTunneling@6294 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
0abb21d962
commit
6760b35ae6
@ -1109,17 +1109,17 @@ bool ftServer::sendData(const std::string& peerId, const std::string& hash, uint
|
||||
{
|
||||
RsTurtleFileDataItem *item = new RsTurtleFileDataItem ;
|
||||
|
||||
item->chunk_offset = offset ;
|
||||
item->chunk_size = chunksize ;
|
||||
item->chunk_data = malloc(chunksize) ;
|
||||
item->chunk_offset = offset+baseoffset ;
|
||||
item->chunk_size = chunk;
|
||||
item->chunk_data = malloc(chunk) ;
|
||||
|
||||
if(item->chunk_data == NULL)
|
||||
{
|
||||
std::cerr << "p3turtle: Warning: failed malloc of " << chunksize << " bytes for sending data packet." << std::endl ;
|
||||
std::cerr << "p3turtle: Warning: failed malloc of " << chunk << " bytes for sending data packet." << std::endl ;
|
||||
delete item;
|
||||
return false;
|
||||
}
|
||||
memcpy(item->chunk_data,(void*)((uint8_t*)data),chunksize) ;
|
||||
memcpy(item->chunk_data,&(((uint8_t *) data)[offset]),chunk) ;
|
||||
|
||||
mTurtleRouter->sendTurtleData(peerId,item) ;
|
||||
}
|
||||
|
@ -877,11 +877,6 @@ void p3turtle::handleSearchRequest(RsTurtleSearchRequestItem *item)
|
||||
res_item = NULL ;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
else
|
||||
std::cerr << " Rejecting local search because strategy is FRIENDS_ONLY and item depth=" << item->depth << std::endl ;
|
||||
#endif
|
||||
}
|
||||
|
||||
// If search depth not too large, also forward this search request to all other peers.
|
||||
@ -1135,17 +1130,29 @@ void p3turtle::sendTurtleData(const std::string& virtual_peer_id,RsTurtleGeneric
|
||||
if(it == _virtual_peers.end())
|
||||
{
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
std::cerr << "p3turtle::senddataRequest: cannot find virtual peer " << peerId << " in VP list." << std::endl ;
|
||||
std::cerr << "p3turtle::senddataRequest: cannot find virtual peer " << virtual_peer_id << " in VP list." << std::endl ;
|
||||
#endif
|
||||
delete item ;
|
||||
return ;
|
||||
}
|
||||
TurtleTunnelId tunnel_id = it->second ;
|
||||
TurtleTunnel& tunnel(_local_tunnels[tunnel_id]) ;
|
||||
std::map<TurtleTunnelId,TurtleTunnel>::iterator it2( _local_tunnels.find(tunnel_id) ) ;
|
||||
|
||||
if(it2 == _local_tunnels.end())
|
||||
{
|
||||
std::cerr << "p3turtle::client asked to send a packet through tunnel that has previously been deleted. Not a big issue unless it happens in masses." << std::endl;
|
||||
delete item ;
|
||||
return ;
|
||||
}
|
||||
TurtleTunnel& tunnel(it2->second) ;
|
||||
|
||||
item->tunnel_id = tunnel_id ; // we should randomly select a tunnel, or something more clever.
|
||||
|
||||
std::string ownid = mLinkMgr->getOwnId() ;
|
||||
|
||||
if(item->shouldStampTunnel())
|
||||
tunnel.time_stamp = time(NULL) ;
|
||||
|
||||
if(tunnel.local_src == ownid)
|
||||
{
|
||||
item->setTravelingDirection(RsTurtleGenericTunnelItem::DIRECTION_SERVER) ;
|
||||
@ -2031,14 +2038,14 @@ void p3turtle::dumpState()
|
||||
std::cerr << " Active incoming file hashes: " << _incoming_file_hashes.size() << std::endl ;
|
||||
for(std::map<TurtleFileHash,TurtleHashInfo>::const_iterator it(_incoming_file_hashes.begin());it!=_incoming_file_hashes.end();++it)
|
||||
{
|
||||
std::cerr << " hash=0x" << it->first << ", name=" << it->second.name << ", size=" << it->second.size << ", tunnel ids =" ;
|
||||
std::cerr << " hash=0x" << it->first << ", tunnel ids =" ;
|
||||
for(std::vector<TurtleTunnelId>::const_iterator it2(it->second.tunnels.begin());it2!=it->second.tunnels.end();++it2)
|
||||
std::cerr << " " << (void*)*it2 ;
|
||||
//std::cerr << ", last_req=" << (void*)it->second.last_request << ", time_stamp = " << it->second.time_stamp << "(" << now-it->second.time_stamp << " secs ago)" << std::endl ;
|
||||
}
|
||||
std::cerr << " Active outgoing file hashes: " << _outgoing_file_hashes.size() << std::endl ;
|
||||
for(std::map<TurtleFileHash,FileInfo>::const_iterator it(_outgoing_file_hashes.begin());it!=_outgoing_file_hashes.end();++it)
|
||||
std::cerr << " hash=0x" << it->first << ", name=" << it->second.fname << ", size=" << it->second.size << std::endl ;
|
||||
for(std::map<TurtleFileHash,std::string>::const_iterator it(_outgoing_file_hashes.begin());it!=_outgoing_file_hashes.end();++it)
|
||||
std::cerr << " hash=0x" << it->first << std::endl ;
|
||||
|
||||
std::cerr << " Local tunnels:" << std::endl ;
|
||||
for(std::map<TurtleTunnelId,TurtleTunnel>::const_iterator it(_local_tunnels.begin());it!=_local_tunnels.end();++it)
|
||||
|
Loading…
Reference in New Issue
Block a user