added chunk request info, and chunk download info. Corrected bug displaying speed for stalled transfers. Warning: needs full recompilation

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3935 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2010-12-26 10:58:02 +00:00
parent 304bbf55cf
commit 40efe19efa
7 changed files with 69 additions and 29 deletions

View file

@ -38,10 +38,10 @@ class ftChunk
friend std::ostream& operator<<(std::ostream& o,const ftChunk& f) ;
uint64_t offset;
uint64_t size;
ChunkId id ;
time_t ts;
uint64_t offset; // current offset of the slice
uint64_t size; // size remaining to download
ChunkId id ; // id of the chunk. Equal to the starting offset of the chunk
time_t ts; // time of last data received
std::string peer_id ;
};

View file

@ -373,30 +373,6 @@ bool ftFileCreator::getMissingChunk(const std::string& peer_id,uint32_t size_hin
#endif
source_chunk_map_needed = false ;
/* check for freed chunks */
time_t ts = time(NULL);
// time_t old = ts-CHUNK_MAX_AGE;
//
// std::map<uint64_t, ftChunk>::iterator it;
// for(it = mChunks.begin(); it != mChunks.end(); it++)
// {
// /* very simple algorithm */
// if (it->second.ts < old)
// {
//#ifdef FILE_DEBUG
// std::cerr << "ffc::getMissingChunk() Re-asking for an old chunk";
// std::cerr << std::endl;
//#endif
//
// /* retry this one */
// it->second.ts = ts;
// size = it->second.size;
// offset = it->second.offset;
//
// return true;
// }
// }
uint32_t& chunks_for_this_peer(mChunksPerPeer[peer_id].cnt) ;
if(chunks_for_this_peer >= MAX_FTCHUNKS_PER_PEER)
@ -433,6 +409,22 @@ void ftFileCreator::getChunkMap(FileChunksInfo& info)
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
chunkMap.getChunksInfo(info) ;
// add info pending requests, handled by ftFileCreator
//
info.pending_slices.clear();
for(std::map<uint64_t, ftChunk>::iterator it = mChunks.begin();it!=mChunks.end();++it)
{
int n = it->second.id / info.chunk_size ;
FileChunksInfo::SliceInfo si ;
si.start = it->second.offset - n*info.chunk_size ;
si.size = it->second.size ;
si.peer_id = it->second.peer_id ;
info.pending_slices[n].push_back(si) ;
}
}
bool ftFileCreator::locked_printChunkMap()