mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-03 06:35:08 -04:00
- removed calls to rsfiles->get{Download,Partials}Directory() in RsDiscSpace class, since it would trigger a call to ftController
- added a lock into ftTransferModule::recvFileData() (Crash reported by Costa due to storing data in a deleted transfer module) - changed names of functions in ftTransferModules to locked_* when appropriate (helps debugging) git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4612 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
3ed0c1d885
commit
97ed1d534f
5 changed files with 75 additions and 57 deletions
|
@ -44,6 +44,8 @@ uint32_t RsDiscSpace::_size_limit_mb = 100 ;
|
|||
uint32_t RsDiscSpace::_current_size[3] = { 10000,10000,10000 } ;
|
||||
bool RsDiscSpace::_last_res[3] = { true,true,true };
|
||||
RsMutex RsDiscSpace::_mtx("RsDiscSpace") ;
|
||||
std::string RsDiscSpace::_partials_path = "" ;
|
||||
std::string RsDiscSpace::_download_path = "" ;
|
||||
|
||||
bool RsDiscSpace::crossSystemDiskStats(const char *file, uint64_t& free_blocks, uint64_t& block_size)
|
||||
{
|
||||
|
@ -111,6 +113,18 @@ bool RsDiscSpace::crossSystemDiskStats(const char *file, uint64_t& free_blocks,
|
|||
return true ;
|
||||
}
|
||||
|
||||
void RsDiscSpace::setDownloadPath(const std::string& path)
|
||||
{
|
||||
RsStackMutex m(_mtx) ; // Locked
|
||||
_download_path = path ;
|
||||
}
|
||||
|
||||
void RsDiscSpace::setPartialsPath(const std::string& path)
|
||||
{
|
||||
RsStackMutex m(_mtx) ; // Locked
|
||||
_partials_path = path ;
|
||||
}
|
||||
|
||||
bool RsDiscSpace::checkForDiscSpace(RsDiscSpace::DiscLocation loc)
|
||||
{
|
||||
RsStackMutex m(_mtx) ; // Locked
|
||||
|
@ -133,15 +147,15 @@ bool RsDiscSpace::checkForDiscSpace(RsDiscSpace::DiscLocation loc)
|
|||
#endif
|
||||
switch(loc)
|
||||
{
|
||||
case RS_DOWNLOAD_DIRECTORY: rs = crossSystemDiskStats(rsFiles->getDownloadDirectory().c_str(),free_blocks,block_size) ;
|
||||
case RS_DOWNLOAD_DIRECTORY: rs = crossSystemDiskStats(_download_path.c_str(),free_blocks,block_size) ;
|
||||
#ifdef DEBUG_RSDISCSPACE
|
||||
std::cerr << " path = " << rsFiles->getDownloadDirectory() << std::endl ;
|
||||
std::cerr << " path = " << _download_path << std::endl ;
|
||||
#endif
|
||||
break ;
|
||||
|
||||
case RS_PARTIALS_DIRECTORY: rs = crossSystemDiskStats(rsFiles->getPartialsDirectory().c_str(),free_blocks,block_size) ;
|
||||
case RS_PARTIALS_DIRECTORY: rs = crossSystemDiskStats(_partials_path.c_str(),free_blocks,block_size) ;
|
||||
#ifdef DEBUG_RSDISCSPACE
|
||||
std::cerr << " path = " << rsFiles->getPartialsDirectory() << std::endl ;
|
||||
std::cerr << " path = " << _partials_path << std::endl ;
|
||||
#endif
|
||||
break ;
|
||||
|
||||
|
|
|
@ -46,6 +46,8 @@ class RsDiscSpace
|
|||
static void setFreeSpaceLimit(uint32_t mega_bytes) ;
|
||||
static uint32_t freeSpaceLimit() ;
|
||||
|
||||
static void setPartialsPath(const std::string& path) ;
|
||||
static void setDownloadPath(const std::string& path) ;
|
||||
private:
|
||||
static bool crossSystemDiskStats(const char *file, uint64_t& free_blocks, uint64_t& block_size) ;
|
||||
|
||||
|
@ -55,5 +57,8 @@ class RsDiscSpace
|
|||
static uint32_t _size_limit_mb ;
|
||||
static uint32_t _current_size[3] ;
|
||||
static bool _last_res[3] ;
|
||||
|
||||
static std::string _partials_path ;
|
||||
static std::string _download_path ;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue