mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
- added a missing pthread_join in file checking, that eventually caused a leak of thread resources
- changed the order of check in tick() to allow cancelling a file that is being checked - removed the hash step from mutex protection git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4113 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
6edee55e57
commit
451c75813d
@ -401,9 +401,6 @@ bool ftTransferModule::queryInactive()
|
|||||||
if (mFileStatus.stat == ftFileStatus::PQIFILE_INIT)
|
if (mFileStatus.stat == ftFileStatus::PQIFILE_INIT)
|
||||||
mFileStatus.stat = ftFileStatus::PQIFILE_DOWNLOADING;
|
mFileStatus.stat = ftFileStatus::PQIFILE_DOWNLOADING;
|
||||||
|
|
||||||
if (mFileStatus.stat == ftFileStatus::PQIFILE_CHECKING)
|
|
||||||
return false ;
|
|
||||||
|
|
||||||
if (mFileStatus.stat != ftFileStatus::PQIFILE_DOWNLOADING)
|
if (mFileStatus.stat != ftFileStatus::PQIFILE_DOWNLOADING)
|
||||||
{
|
{
|
||||||
if (mFileStatus.stat == ftFileStatus::PQIFILE_FAIL_CANCEL)
|
if (mFileStatus.stat == ftFileStatus::PQIFILE_FAIL_CANCEL)
|
||||||
@ -411,6 +408,9 @@ bool ftTransferModule::queryInactive()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mFileStatus.stat == ftFileStatus::PQIFILE_CHECKING)
|
||||||
|
return false ;
|
||||||
|
|
||||||
std::map<std::string,peerInfo>::iterator mit;
|
std::map<std::string,peerInfo>::iterator mit;
|
||||||
for(mit = mFileSources.begin(); mit != mFileSources.end(); mit++)
|
for(mit = mFileSources.begin(); mit != mFileSources.end(); mit++)
|
||||||
{
|
{
|
||||||
@ -522,8 +522,14 @@ class HashThread: public RsThread
|
|||||||
|
|
||||||
virtual void run()
|
virtual void run()
|
||||||
{
|
{
|
||||||
|
#ifdef FT_DEBUG
|
||||||
|
std::cerr << "hash thread is running for file " << std::endl;
|
||||||
|
#endif
|
||||||
|
std::string tmphash ;
|
||||||
|
_m->hashReceivedData(tmphash) ;
|
||||||
|
|
||||||
RsStackMutex stack(_hashThreadMtx) ;
|
RsStackMutex stack(_hashThreadMtx) ;
|
||||||
_m->hashReceivedData(_hash) ;
|
_hash = tmphash ;
|
||||||
_finished = true ;
|
_finished = true ;
|
||||||
}
|
}
|
||||||
std::string hash()
|
std::string hash()
|
||||||
@ -575,6 +581,8 @@ bool ftTransferModule::checkFile()
|
|||||||
|
|
||||||
std::string check_hash( _hash_thread->hash() ) ;
|
std::string check_hash( _hash_thread->hash() ) ;
|
||||||
|
|
||||||
|
_hash_thread->join(); // allow releasing of resources when finished.
|
||||||
|
|
||||||
delete _hash_thread ;
|
delete _hash_thread ;
|
||||||
_hash_thread = NULL ;
|
_hash_thread = NULL ;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user