mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-18 20:34:26 -05:00
suppressed an initialized memory read. It happens below, but this limits its impact above.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1039 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
543e27a1da
commit
acaa10d54f
@ -181,109 +181,110 @@ bool ftController::completeFile(std::string hash)
|
|||||||
uint32_t callbackCode = 0;
|
uint32_t callbackCode = 0;
|
||||||
|
|
||||||
|
|
||||||
{ RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
|
||||||
|
|
||||||
std::cerr << "ftController:completeFile(" << hash << ")";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
|
|
||||||
std::map<std::string, ftFileControl>::iterator it;
|
|
||||||
it = mDownloads.find(hash);
|
|
||||||
if (it == mDownloads.end())
|
|
||||||
{
|
{
|
||||||
std::cerr << "ftController:completeFile(" << hash << ")";
|
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||||
std::cerr << " Not Found!";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* check if finished */
|
|
||||||
if (!(it->second).mCreator->finished())
|
|
||||||
{
|
|
||||||
/* not done! */
|
|
||||||
std::cerr << "ftController:completeFile(" << hash << ")";
|
std::cerr << "ftController:completeFile(" << hash << ")";
|
||||||
std::cerr << " Transfer Not Done";
|
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
std::cerr << "FileSize: ";
|
std::map<std::string, ftFileControl>::iterator it;
|
||||||
std::cerr << (it->second).mCreator->getFileSize();
|
it = mDownloads.find(hash);
|
||||||
std::cerr << " and Recvd: ";
|
if (it == mDownloads.end())
|
||||||
std::cerr << (it->second).mCreator->getRecvd();
|
{
|
||||||
|
std::cerr << "ftController:completeFile(" << hash << ")";
|
||||||
|
std::cerr << " Not Found!";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
/* check if finished */
|
||||||
}
|
if (!(it->second).mCreator->finished())
|
||||||
|
{
|
||||||
|
/* not done! */
|
||||||
|
std::cerr << "ftController:completeFile(" << hash << ")";
|
||||||
|
std::cerr << " Transfer Not Done";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
std::cerr << "FileSize: ";
|
||||||
|
std::cerr << (it->second).mCreator->getFileSize();
|
||||||
|
std::cerr << " and Recvd: ";
|
||||||
|
std::cerr << (it->second).mCreator->getRecvd();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ftFileControl *fc = &(it->second);
|
ftFileControl *fc = &(it->second);
|
||||||
|
|
||||||
// (csoler) I've postponed this to the end of the block because deleting the
|
// (csoler) I've postponed this to the end of the block because deleting the
|
||||||
// element from the map calls the destructor of fc->mTransfer, which
|
// element from the map calls the destructor of fc->mTransfer, which
|
||||||
// makes fc to point to nothing and causes random behavior/crashes.
|
// makes fc to point to nothing and causes random behavior/crashes.
|
||||||
//
|
//
|
||||||
// mDataplex->removeTransferModule(fc->mTransfer->hash());
|
// mDataplex->removeTransferModule(fc->mTransfer->hash());
|
||||||
//
|
//
|
||||||
/* done - cleanup */
|
/* done - cleanup */
|
||||||
|
|
||||||
// (csoler) I'm copying this because "delete fc->mTransfer" deletes the hash string!
|
// (csoler) I'm copying this because "delete fc->mTransfer" deletes the hash string!
|
||||||
std::string hash_to_suppress(fc->mTransfer->hash());
|
std::string hash_to_suppress(fc->mTransfer->hash());
|
||||||
|
|
||||||
if (fc->mTransfer)
|
if (fc->mTransfer)
|
||||||
{
|
{
|
||||||
delete fc->mTransfer;
|
delete fc->mTransfer;
|
||||||
fc->mTransfer = NULL;
|
fc->mTransfer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fc->mCreator)
|
if (fc->mCreator)
|
||||||
{
|
{
|
||||||
delete fc->mCreator;
|
delete fc->mCreator;
|
||||||
fc->mCreator = NULL;
|
fc->mCreator = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
fc->mState = ftFileControl::COMPLETED;
|
fc->mState = ftFileControl::COMPLETED;
|
||||||
|
|
||||||
/* Move to Correct Location */
|
/* Move to Correct Location */
|
||||||
if (0 == rename(fc->mCurrentPath.c_str(), fc->mDestination.c_str()))
|
if (0 == rename(fc->mCurrentPath.c_str(), fc->mDestination.c_str()))
|
||||||
{
|
{
|
||||||
#ifdef CONTROL_DEBUG
|
#ifdef CONTROL_DEBUG
|
||||||
std::cerr << "ftController::completeFile() renaming to: ";
|
std::cerr << "ftController::completeFile() renaming to: ";
|
||||||
std::cerr << fc->mDestination;
|
std::cerr << fc->mDestination;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* correct the file_name */
|
/* correct the file_name */
|
||||||
fc->mCurrentPath = fc->mDestination;
|
fc->mCurrentPath = fc->mDestination;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef CONTROL_DEBUG
|
#ifdef CONTROL_DEBUG
|
||||||
std::cerr << "ftController::completeFile() FAILED mv to: ";
|
std::cerr << "ftController::completeFile() FAILED mv to: ";
|
||||||
std::cerr << fc->mDestination;
|
std::cerr << fc->mDestination;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fc->mState = ftFileControl::ERROR_COMPLETION;
|
fc->mState = ftFileControl::ERROR_COMPLETION;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* switch map */
|
/* switch map */
|
||||||
if (fc->mFlags & RS_FILE_HINTS_CACHE) /* clean up completed cache files automatically */
|
if (fc->mFlags & RS_FILE_HINTS_CACHE) /* clean up completed cache files automatically */
|
||||||
{
|
{
|
||||||
mCompleted[fc->mHash] = *fc;
|
mCompleted[fc->mHash] = *fc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* for extralist additions */
|
/* for extralist additions */
|
||||||
path = fc->mDestination;
|
path = fc->mDestination;
|
||||||
//hash = fc->mHash;
|
//hash = fc->mHash;
|
||||||
size = fc->mSize;
|
size = fc->mSize;
|
||||||
state = fc->mState;
|
state = fc->mState;
|
||||||
period = 30 * 24 * 3600; /* 30 days */
|
period = 30 * 24 * 3600; /* 30 days */
|
||||||
flags = 0;
|
flags = 0;
|
||||||
|
|
||||||
doCallback = fc->mDoCallback;
|
doCallback = fc->mDoCallback;
|
||||||
callbackCode = fc->mCallbackCode;
|
callbackCode = fc->mCallbackCode;
|
||||||
|
|
||||||
mDataplex->removeTransferModule(hash_to_suppress) ;
|
mDataplex->removeTransferModule(hash_to_suppress) ;
|
||||||
mDownloads.erase(it);
|
mDownloads.erase(it);
|
||||||
} /******* UNLOCKED ********/
|
} /******* UNLOCKED ********/
|
||||||
|
|
||||||
|
|
||||||
/******************** NO Mutex from Now ********************
|
/******************** NO Mutex from Now ********************
|
||||||
@ -394,15 +395,16 @@ bool ftController::FileRequest(std::string fname, std::string hash,
|
|||||||
* or have a callback which says: local file.
|
* or have a callback which says: local file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{ RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
|
||||||
if (!mFtActive)
|
|
||||||
{
|
{
|
||||||
/* store in pending queue */
|
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||||
ftPendingRequest req(fname, hash, size, dest, flags, srcIds);
|
if (!mFtActive)
|
||||||
mPendingRequests.push_back(req);
|
{
|
||||||
return true;
|
/* store in pending queue */
|
||||||
|
ftPendingRequest req(fname, hash, size, dest, flags, srcIds);
|
||||||
|
mPendingRequests.push_back(req);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* check if we have the file */
|
/* check if we have the file */
|
||||||
FileInfo info;
|
FileInfo info;
|
||||||
@ -902,9 +904,9 @@ bool ftController::FileDetails(std::string hash, FileInfo &info)
|
|||||||
it->second.mTransfer->getFileSources(peerIds);
|
it->second.mTransfer->getFileSources(peerIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
double totalRate;
|
double totalRate = 0;
|
||||||
uint32_t tfRate;
|
uint32_t tfRate = 0;
|
||||||
uint32_t state;
|
uint32_t state = 0;
|
||||||
|
|
||||||
bool isDownloading = false;
|
bool isDownloading = false;
|
||||||
bool isSuspended = false;
|
bool isSuspended = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user