added proper dynamic suppression of sources from chunkmap, and updated the gui

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2498 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2010-03-07 14:42:13 +00:00
parent 1c2683f613
commit 5f7486f160
8 changed files with 57 additions and 31 deletions

View File

@ -402,6 +402,16 @@ void ChunkMap::getChunksInfo(FileChunksInfo& info) const
info.compressed_peer_availability_maps[it->first] = it->second.cmap ;
}
void ChunkMap::removeFileSource(const std::string& peer_id)
{
std::map<std::string,SourceChunksInfo>::iterator it(_peers_chunks_availability.find(peer_id)) ;
if(it == _peers_chunks_availability.end())
return ;
_peers_chunks_availability.erase(it) ;
}
void ChunkMap::getAvailabilityMap(CompressedChunkMap& compressed_map) const
{
compressed_map = CompressedChunkMap(_map) ;

View File

@ -135,6 +135,9 @@ class ChunkMap
virtual void getAvailabilityMap(CompressedChunkMap& cmap) const ;
void setAvailabilityMap(const CompressedChunkMap& cmap) ;
/// Removes the source availability map. The map
void removeFileSource(const std::string& peer_id) ;
/// This function fills in a plain map for a file of the given size. This
/// is used to ensure that the chunk size will be consistent with the rest
/// of the code.

View File

@ -181,6 +181,7 @@ void ftController::removeFileSource(const std::string& hash,const std::string& p
if(it->first == hash)
{
it->second->mTransfer->removeFileSource(peer_id);
it->second->mCreator->removeFileSource(peer_id);
// setPeerState(it->second.mTransfer, peer_id, rate, mConnMgr->isOnline(peer_id));

View File

@ -177,6 +177,15 @@ void ftFileCreator::removeInactiveChunks()
#endif
}
void ftFileCreator::removeFileSource(const std::string& peer_id)
{
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
#ifdef FILE_DEBUG
std::cerr << "ftFileCreator:: removign file source " << peer_id << " from chunkmap." << std::endl ;
#endif
chunkMap.removeFileSource(peer_id) ;
}
int ftFileCreator::initializeFileAttrs()
{
#ifdef FILE_DEBUG

View File

@ -73,6 +73,9 @@ class ftFileCreator: public ftFileProvider
//
void removeInactiveChunks() ;
// removes the designated file source from the chunkmap.
void removeFileSource(const std::string& peer_id) ;
// Returns the time stamp of the last data receive.
time_t lastRecvTimeStamp() ;

View File

@ -217,28 +217,28 @@ void ftFileProvider::getClientMap(const std::string& peer_id,CompressedChunkMap&
int ftFileProvider::initializeFileAttrs()
{
#ifdef DEBUG_FT_FILE_PROVIDER
std::cerr << "ftFileProvider::initializeFileAttrs() Filename: " << file_name << std::endl;
#endif
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
#ifdef DEBUG_FT_FILE_PROVIDER
std::cerr << "ftFileProvider::initializeFileAttrs() Filename: " << file_name << std::endl;
#endif
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
if (fd)
return 1;
/*
* check if the file exists
*/
* check if the file exists
*/
{
#ifdef DEBUG_FT_FILE_PROVIDER
std::cerr << "ftFileProvider::initializeFileAttrs() trying (r+b) " << std::endl;
#endif
#ifdef DEBUG_FT_FILE_PROVIDER
std::cerr << "ftFileProvider::initializeFileAttrs() trying (r+b) " << std::endl;
#endif
}
/*
* attempt to open file
*/
* attempt to open file
*/
fd = fopen64(file_name.c_str(), "rb");
if (!fd)
{
@ -251,28 +251,28 @@ int ftFileProvider::initializeFileAttrs()
{
std::cerr << "ftFileProvider::initializeFileAttrs() Failed to open (rb): ";
std::cerr << file_name << std::endl;
/* try opening read only */
return 0;
}
}
/*
* if it opened, find it's length
* if it opened, find it's length
* move to the end
*/
if (0 != fseeko64(fd, 0L, SEEK_END))
{
std::cerr << "ftFileProvider::initializeFileAttrs() Seek Failed" << std::endl;
return 0;
}
*/
uint64_t recvdsize = ftello64(fd);
// if (0 != fseeko64(fd, 0L, SEEK_END))
// {
// std::cerr << "ftFileProvider::initializeFileAttrs() Seek Failed" << std::endl;
// return 0;
// }
//
// uint64_t recvdsize = ftello64(fd);
//
//#ifdef DEBUG_FT_FILE_PROVIDER
// std::cerr << "ftFileProvider::initializeFileAttrs() File Expected Size: " << mSize << " RecvdSize: " << recvdsize << std::endl;
//#endif
#ifdef DEBUG_FT_FILE_PROVIDER
std::cerr << "ftFileProvider::initializeFileAttrs() File Expected Size: " << mSize << " RecvdSize: " << recvdsize << std::endl;
#endif
return 1;
}

View File

@ -247,9 +247,9 @@ void p3turtle::autoWash()
if(it == _incoming_file_hashes.end())
{
#ifdef P3TURTLE_DEBUG
#ifdef P3TURTLE_DEBUG
std::cerr << "p3turtle: asked to stop monitoring file hash " << _hashes_to_remove[i] << ", but this hash is actually not handled by the turtle router." << std::endl ;
#endif
#endif
continue ;
}

View File

@ -187,7 +187,7 @@ void FileTransferInfoWidget::draw(const FileInfo& nfo,const FileChunksInfo& info
y += block_sep ;
y += text_height ;
painter->setPen(QColor::fromRgb(0,0,0)) ;
painter->drawText(0,y,tr("Availability map (")+QString::number(info.compressed_peer_availability_maps.size())+ tr(" sources")+")") ;
painter->drawText(0,y,tr("Availability map (")+QString::number(info.compressed_peer_availability_maps.size())+ tr(" active sources")+")") ;
y += block_sep ;
// Note (for non geeks): the !! operator transforms anything positive into 1 and 0 into 0.