From 48556396ee8ed6192c053dfbecffdc388ce0a1be Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 14 May 2010 11:29:15 +0000 Subject: [PATCH] added a check to avoid (possibly rare) data races git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2901 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/ft/ftdatamultiplex.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libretroshare/src/ft/ftdatamultiplex.cc b/libretroshare/src/ft/ftdatamultiplex.cc index 8403082df..3d45a8db0 100644 --- a/libretroshare/src/ft/ftdatamultiplex.cc +++ b/libretroshare/src/ft/ftdatamultiplex.cc @@ -478,7 +478,11 @@ bool ftDataMultiplex::handleRecvServerChunkMapRequest(const std::string& peerId, RsStackMutex stack(dataMtx); /******* LOCK MUTEX ******/ it = mServers.find(hash) ; - it->second->getAvailabilityMap(cmap); + + if(it == mServers.end()) // handleSearchRequest should have filled mServers[hash], but we have been off-mutex since, + return false ; // so it's safer to check again. + else + it->second->getAvailabilityMap(cmap); } mDataSend->sendChunkMap(peerId,hash,cmap);