From 3012683143e407982abd86d9ad5b474b734c6297 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 26 Jan 2009 18:55:33 +0000 Subject: [PATCH] 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 --- libretroshare/src/ft/ftcontroller.cc | 10 +++++++++- libretroshare/src/ft/ftserver.cc | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libretroshare/src/ft/ftcontroller.cc b/libretroshare/src/ft/ftcontroller.cc index 2af200ebc..e6fd83de8 100644 --- a/libretroshare/src/ft/ftcontroller.cc +++ b/libretroshare/src/ft/ftcontroller.cc @@ -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 ********/ diff --git a/libretroshare/src/ft/ftserver.cc b/libretroshare/src/ft/ftserver.cc index 078d08fc2..e255031a5 100644 --- a/libretroshare/src/ft/ftserver.cc +++ b/libretroshare/src/ft/ftserver.cc @@ -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