diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2012-05-13 17:55:23 +0200 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2012-05-18 16:56:12 +0200 |
commit | 660ff174f299a6dfb28f7725dfbb08f140a5474b (patch) | |
tree | 4d3c52db399ace118c871fc92715fd8836f02201 /src/sync.cpp | |
parent | 4a9130aca20af3f82b7ddd62afe5ce85a845e425 (diff) |
Use boost::thread locking instead of interprocess
Diffstat (limited to 'src/sync.cpp')
-rw-r--r-- | src/sync.cpp | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/src/sync.cpp b/src/sync.cpp index fd9bcb62bc..d8d86d525e 100644 --- a/src/sync.cpp +++ b/src/sync.cpp @@ -3,8 +3,9 @@ // file license.txt or http://www.opensource.org/licenses/mit-license.php. #include "sync.h" +#include "util.h" - +#include <boost/foreach.hpp> #ifdef DEBUG_LOCKORDER // @@ -40,7 +41,7 @@ private: typedef std::vector< std::pair<void*, CLockLocation> > LockStack; -static boost::interprocess::interprocess_mutex dd_mutex; +static boost::mutex dd_mutex; static std::map<std::pair<void*, void*>, LockStack> lockorders; static boost::thread_specific_ptr<LockStack> lockstack; @@ -66,7 +67,6 @@ static void potential_deadlock_detected(const std::pair<void*, void*>& mismatch, static void push_lock(void* c, const CLockLocation& locklocation, bool fTry) { - bool fOrderOK = true; if (lockstack.get() == NULL) lockstack.reset(new LockStack); @@ -75,20 +75,21 @@ static void push_lock(void* c, const CLockLocation& locklocation, bool fTry) (*lockstack).push_back(std::make_pair(c, locklocation)); - if (!fTry) BOOST_FOREACH(const PAIRTYPE(void*, CLockLocation)& i, (*lockstack)) - { - if (i.first == c) break; - - std::pair<void*, void*> p1 = std::make_pair(i.first, c); - if (lockorders.count(p1)) - continue; - lockorders[p1] = (*lockstack); - - std::pair<void*, void*> p2 = std::make_pair(c, i.first); - if (lockorders.count(p2)) - { - potential_deadlock_detected(p1, lockorders[p2], lockorders[p1]); - break; + if (!fTry) { + BOOST_FOREACH(const PAIRTYPE(void*, CLockLocation)& i, (*lockstack)) { + if (i.first == c) break; + + std::pair<void*, void*> p1 = std::make_pair(i.first, c); + if (lockorders.count(p1)) + continue; + lockorders[p1] = (*lockstack); + + std::pair<void*, void*> p2 = std::make_pair(c, i.first); + if (lockorders.count(p2)) + { + potential_deadlock_detected(p1, lockorders[p2], lockorders[p1]); + break; + } } } dd_mutex.unlock(); |