Corrected two nasty bugs in file transfer which caused random core dumps (at least on ubuntu 32 and 64 bits)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@957 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2009-01-26 18:55:33 +00:00
parent c43b3ae617
commit 3012683143
2 changed files with 10 additions and 2 deletions

View File

@ -215,9 +215,16 @@ bool ftController::completeFile(std::string hash)
ftFileControl *fc = &(it->second);
// (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
// makes fc to point to nothing and causes random behavior/crashes.
//
// mDataplex->removeTransferModule(fc->mTransfer->hash());
//
/* done - cleanup */
mDataplex->removeTransferModule(fc->mTransfer->hash());
// (csoler) I'm copying this because "delete fc->mTransfer" deletes the hash string!
std::string hash_to_suppress(fc->mTransfer->hash());
if (fc->mTransfer)
{
@ -274,6 +281,7 @@ bool ftController::completeFile(std::string hash)
doCallback = fc->mDoCallback;
callbackCode = fc->mCallbackCode;
mDataplex->removeTransferModule(hash_to_suppress) ;
mDownloads.erase(it);
} /******* UNLOCKED ********/

View File

@ -204,8 +204,8 @@ void ftServer::run()
for (it = toDels.begin();it != toDels.end(); it++)
{
sit = mFtDataplex->mServers.find(*it);
mFtDataplex->mServers.erase(sit);
delete sit->second;
mFtDataplex->mServers.erase(sit);
}
#ifdef WIN32