From 98911955d5aea83281f403c322faf69d67d50e50 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 9 Feb 2009 20:26:12 +0000 Subject: [PATCH] Possibly got rid of this core dump in file uploads. It seems it came from unlocked destroying of dataplex->mServers when they came out of time, while the gui still asked for info about them. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1030 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/ft/ftdatamultiplex.cc | 15 +++++++++++++++ libretroshare/src/ft/ftdatamultiplex.h | 3 +++ libretroshare/src/ft/ftserver.cc | 15 +++------------ 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/libretroshare/src/ft/ftdatamultiplex.cc b/libretroshare/src/ft/ftdatamultiplex.cc index 2ad23a4b9..0c25f6182 100644 --- a/libretroshare/src/ft/ftdatamultiplex.cc +++ b/libretroshare/src/ft/ftdatamultiplex.cc @@ -443,6 +443,21 @@ bool ftDataMultiplex::locked_handleServerRequest(ftFileProvider *provider, return false; } +void ftDataMultiplex::deleteServers(const std::list& serv) +{ + RsStackMutex stack(dataMtx); /******* LOCK MUTEX ******/ + + for(std::list::const_iterator it=serv.begin();it != serv.end(); it++) + { + std::map::iterator sit = mServers.find(*it); + + if(mServers.end() != sit) + { + delete sit->second; + mServers.erase(sit); + } + } +} bool ftDataMultiplex::handleSearchRequest(std::string peerId, std::string hash, uint64_t size, diff --git a/libretroshare/src/ft/ftdatamultiplex.h b/libretroshare/src/ft/ftdatamultiplex.h index 8c2a25740..fbcefd19a 100644 --- a/libretroshare/src/ft/ftdatamultiplex.h +++ b/libretroshare/src/ft/ftdatamultiplex.h @@ -96,6 +96,9 @@ bool FileUploads(std::list &hashs); bool FileDownloads(std::list &hashs); bool FileDetails(std::string hash, uint32_t hintsflag, FileInfo &info); +void deleteServers(const std::list& serv_hash) ; + + /*************** SEND INTERFACE (calls ftDataSend) *******************/ /* Client Send */ diff --git a/libretroshare/src/ft/ftserver.cc b/libretroshare/src/ft/ftserver.cc index da6318b5f..5c13b27ae 100644 --- a/libretroshare/src/ft/ftserver.cc +++ b/libretroshare/src/ft/ftserver.cc @@ -203,18 +203,9 @@ void ftServer::run() } } - std::list::iterator it; - for (it = toDels.begin();it != toDels.end(); it++) - { - sit = mFtDataplex->mServers.find(*it); - - if(mFtDataplex->mServers.end() != sit) - { - delete sit->second; - mFtDataplex->mServers.erase(sit); - } - } - + if(!toDels.empty()) + mFtDataplex->deleteServers(toDels) ; + #ifdef WIN32 Sleep(1000); #else