From a9c1b51e82a26446e5afd83346a87a8f5a07b977 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Fri, 5 Oct 2012 13:05:10 -0700 Subject: [PATCH] Temporary fix for the deadlock. --- src/FieldNames.cpp | 8 ++++---- src/FieldNames.h | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/FieldNames.cpp b/src/FieldNames.cpp index 2946ca2552..122550eb18 100644 --- a/src/FieldNames.cpp +++ b/src/FieldNames.cpp @@ -11,7 +11,7 @@ // These must stay at the top of this file std::map SField::codeToField; -boost::mutex SField::mapMutex; +boost::recursive_mutex SField::mapMutex; SField sfInvalid(-1), sfGeneric(0); SField sfLedgerEntry(STI_LEDGERENTRY, 1, "LedgerEntry"); @@ -34,7 +34,7 @@ SField::ref SField::getField(int code) if ((type <= 0) || (field <= 0)) return sfInvalid; - boost::mutex::scoped_lock sl(mapMutex); + boost::recursive_mutex::scoped_lock sl(mapMutex); std::map::iterator it = codeToField.find(code); if (it != codeToField.end()) @@ -84,7 +84,7 @@ std::string SField::getName() const SField::ref SField::getField(const std::string& fieldName) { // OPTIMIZEME me with a map. CHECKME this is case sensitive - boost::mutex::scoped_lock sl(mapMutex); + boost::recursive_mutex::scoped_lock sl(mapMutex); typedef std::pair int_sfref_pair; BOOST_FOREACH(const int_sfref_pair& fieldPair, codeToField) { @@ -96,7 +96,7 @@ SField::ref SField::getField(const std::string& fieldName) SField::~SField() { - boost::mutex::scoped_lock sl(mapMutex); + boost::recursive_mutex::scoped_lock sl(mapMutex); std::map::iterator it = codeToField.find(fieldCode); if ((it != codeToField.end()) && (it->second == this)) codeToField.erase(it); diff --git a/src/FieldNames.h b/src/FieldNames.h index cea532fb63..2933fd2aa1 100644 --- a/src/FieldNames.h +++ b/src/FieldNames.h @@ -3,7 +3,7 @@ #include -#include +#include #define FIELD_CODE(type, index) ((static_cast(type) << 16) | index) @@ -40,8 +40,8 @@ public: typedef SField const * ptr; protected: - static std::map codeToField; - static boost::mutex mapMutex; + static std::map codeToField; + static boost::recursive_mutex mapMutex; public: @@ -53,14 +53,14 @@ public: SField(int fc, SerializedTypeID tid, int fv, const char* fn) : fieldCode(fc), fieldType(tid), fieldValue(fv), fieldName(fn) { - boost::mutex::scoped_lock sl(mapMutex); + boost::recursive_mutex::scoped_lock sl(mapMutex); codeToField[fieldCode] = this; } SField(SerializedTypeID tid, int fv, const char *fn) : fieldCode(FIELD_CODE(tid, fv)), fieldType(tid), fieldValue(fv), fieldName(fn) { - boost::mutex::scoped_lock sl(mapMutex); + boost::recursive_mutex::scoped_lock sl(mapMutex); codeToField[fieldCode] = this; }