ported v0.5.0 commits 2561,2562 and 2574 to trunk

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2575 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2010-03-17 15:34:36 +00:00
parent 12a0f45625
commit f8d6590952
10 changed files with 134 additions and 90 deletions

View file

@ -727,6 +727,7 @@ bool ftController::completeFile(std::string hash)
if (fc->mCreator)
{
fc->mCreator->closeFile() ;
delete fc->mCreator;
fc->mCreator = NULL;
}
@ -929,6 +930,11 @@ bool ftController::FileRequest(std::string fname, std::string hash,
uint64_t size, std::string dest, uint32_t flags,
std::list<std::string> &srcIds)
{
/* check if we have the file */
if(alreadyHaveFile(hash))
return false ;
if(size == 0) // we treat this special case because
{
/* if no destpath - send to download directory */
@ -967,11 +973,6 @@ bool ftController::FileRequest(std::string fname, std::string hash,
}
}
/* check if we have the file */
if(alreadyHaveFile(hash))
return true ;
FileInfo info;
std::list<std::string>::iterator it;
std::list<TransferInfo>::iterator pit;

View file

@ -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(). */
/* Check File is open */
if (fd == NULL)
if (!initializeFileAttrs())
return false;
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
if (fd == NULL)
if (!locked_initializeFileAttrs())
return false;
/*
* check its at the correct location
*/
@ -109,13 +109,13 @@ bool ftFileCreator::addFileData(uint64_t offset, uint32_t chunk_size, void *data
*/
if (0 != fseeko64(this->fd, offset, SEEK_SET))
{
std::cerr << "ftFileCreator::addFileData() Bad fseek" << std::endl;
std::cerr << "ftFileCreator::addFileData() Bad fseek at offset " << offset << ", fd=" << (void*)(this->fd) << ", size=" << mSize << ", errno=" << errno << std::endl;
return 0;
}
if (1 != fwrite(data, chunk_size, 1, this->fd))
{
std::cerr << "ftFileCreator::addFileData() Bad fwrite" << std::endl;
std::cerr << "ftFileCreator::addFileData() Bad fwrite." << std::endl;
std::cerr << "ERRNO: " << errno << std::endl;
return 0;
@ -186,36 +186,35 @@ void ftFileCreator::removeFileSource(const std::string& peer_id)
chunkMap.removeFileSource(peer_id) ;
}
int ftFileCreator::initializeFileAttrs()
int ftFileCreator::locked_initializeFileAttrs()
{
#ifdef FILE_DEBUG
std::cerr << "ftFileCreator::initializeFileAttrs() Filename: " << file_name << " this: " << this << std::endl;
#endif
#ifdef FILE_DEBUG
std::cerr << "ftFileCreator::initializeFileAttrs() Filename: " << file_name << " this: " << this << std::endl;
#endif
/*
* check if the file exists
* check if the file exists
* cant use FileProviders verion because that opens readonly.
*/
*/
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
if (fd)
return 1;
/*
* check if the file exists
*/
* check if the file exists
*/
{
#ifdef FILE_DEBUG
std::cerr << "ftFileCreator::initializeFileAttrs() trying (r+b) " << file_name << " this: " << this << std::endl;
#endif
#ifdef FILE_DEBUG
std::cerr << "ftFileCreator::initializeFileAttrs() trying (r+b) " << file_name << " this: " << this << std::endl;
#endif
std::cerr << std::endl;
}
/*
* attempt to open file
*/
* attempt to open file
*/
fd = fopen64(file_name.c_str(), "r+b");
if (!fd)
@ -235,21 +234,6 @@ int ftFileCreator::initializeFileAttrs()
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
std::cerr << "ftFileCreator::initializeFileAttrs() File Expected Size: " << mSize << " RecvdSize: " << recvdsize << std::endl;
#endif

View file

@ -98,7 +98,7 @@ class ftFileCreator: public ftFileProvider
protected:
virtual int initializeFileAttrs();
virtual int locked_initializeFileAttrs();
private:

View file

@ -1346,11 +1346,13 @@ bool AuthGPG::SignDataBin(std::string input, unsigned char *sign, unsigned int *
}
bool AuthGPG::SignDataBin(const void *data, unsigned int datalen, unsigned char *sign, unsigned int *signlen) {
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
return DoOwnSignature_locked(data, datalen,
sign, signlen);
}
bool AuthGPG::VerifySignBin(const void *data, uint32_t datalen, unsigned char *sign, unsigned int signlen, std::string withfingerprint) {
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
return VerifySignature_locked(data, datalen,
sign, signlen, withfingerprint);
}
@ -1360,6 +1362,7 @@ bool AuthGPG::VerifySignBin(const void *data, uint32_t datalen, unsigned char *s
int AuthGPG::privateSignCertificate(std::string id)
{
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
/* The key should be in Others list and not in Peers list ??
* Once the key is signed, it moves from Others to Peers list ???
*/