mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-20 20:31:46 -05:00
added proper close for file transfers. This drops down the number of FDs from 250 to ... 50 svn status
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5.0@2562 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
a914e463d3
commit
1d016a6ceb
@ -727,6 +727,7 @@ bool ftController::completeFile(std::string hash)
|
|||||||
|
|
||||||
if (fc->mCreator)
|
if (fc->mCreator)
|
||||||
{
|
{
|
||||||
|
fc->mCreator->closeFile() ;
|
||||||
delete fc->mCreator;
|
delete fc->mCreator;
|
||||||
fc->mCreator = NULL;
|
fc->mCreator = NULL;
|
||||||
}
|
}
|
||||||
|
@ -88,12 +88,12 @@ bool ftFileCreator::addFileData(uint64_t offset, uint32_t chunk_size, void *data
|
|||||||
/* dodgey checking outside of mutex... much check again inside FileAttrs(). */
|
/* dodgey checking outside of mutex... much check again inside FileAttrs(). */
|
||||||
/* Check File is open */
|
/* Check File is open */
|
||||||
|
|
||||||
if (fd == NULL)
|
|
||||||
if (!initializeFileAttrs())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
|
if (fd == NULL)
|
||||||
|
if (!locked_initializeFileAttrs())
|
||||||
|
return false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* check its at the correct location
|
* check its at the correct location
|
||||||
*/
|
*/
|
||||||
@ -186,36 +186,35 @@ void ftFileCreator::removeFileSource(const std::string& peer_id)
|
|||||||
chunkMap.removeFileSource(peer_id) ;
|
chunkMap.removeFileSource(peer_id) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ftFileCreator::initializeFileAttrs()
|
int ftFileCreator::locked_initializeFileAttrs()
|
||||||
{
|
{
|
||||||
#ifdef FILE_DEBUG
|
#ifdef FILE_DEBUG
|
||||||
std::cerr << "ftFileCreator::initializeFileAttrs() Filename: " << file_name << " this: " << this << std::endl;
|
std::cerr << "ftFileCreator::initializeFileAttrs() Filename: " << file_name << " this: " << this << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* check if the file exists
|
* check if the file exists
|
||||||
* cant use FileProviders verion because that opens readonly.
|
* cant use FileProviders verion because that opens readonly.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
|
|
||||||
if (fd)
|
if (fd)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* check if the file exists
|
* check if the file exists
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
#ifdef FILE_DEBUG
|
#ifdef FILE_DEBUG
|
||||||
std::cerr << "ftFileCreator::initializeFileAttrs() trying (r+b) " << file_name << " this: " << this << std::endl;
|
std::cerr << "ftFileCreator::initializeFileAttrs() trying (r+b) " << file_name << " this: " << this << std::endl;
|
||||||
#endif
|
#endif
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* attempt to open file
|
* attempt to open file
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fd = fopen64(file_name.c_str(), "r+b");
|
fd = fopen64(file_name.c_str(), "r+b");
|
||||||
|
|
||||||
if (!fd)
|
if (!fd)
|
||||||
@ -235,21 +234,6 @@ int ftFileCreator::initializeFileAttrs()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* if it opened, find it's length
|
|
||||||
* move to the end
|
|
||||||
*/
|
|
||||||
|
|
||||||
// if (0 != fseeko64(fd, 0L, SEEK_END))
|
|
||||||
// {
|
|
||||||
// std::cerr << "ftFileCreator::initializeFileAttrs() Seek Failed" << std::endl;
|
|
||||||
// return 0;
|
|
||||||
// }
|
|
||||||
|
|
||||||
#ifdef FILE_DEBUG
|
#ifdef FILE_DEBUG
|
||||||
std::cerr << "ftFileCreator::initializeFileAttrs() File Expected Size: " << mSize << " RecvdSize: " << recvdsize << std::endl;
|
std::cerr << "ftFileCreator::initializeFileAttrs() File Expected Size: " << mSize << " RecvdSize: " << recvdsize << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
@ -98,7 +98,7 @@ class ftFileCreator: public ftFileProvider
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual int initializeFileAttrs();
|
virtual int locked_initializeFileAttrs();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user