aboutsummaryrefslogtreecommitdiff
path: root/src/sync.h
Commit message (Collapse)AuthorAgeFilesLines
* sync: Add RecursiveMutex type aliasMarcoFalke2018-12-141-1/+2
|
* scripted-diff: Small locking renameRussell Yanofsky2018-08-311-9/+6
| | | | | | | | | | | | | | | | | | | | | | | Call sync.h primitives "locks" and "mutexes" instead of "blocks" and "waitable critical sections" to match current coding conventions and c++11 standard names. This PR does not rename the "CCriticalSection" class (though this could be done as a followup) because it is used everywhere and would swamp the other changes in this PR. Plain mutexes should mostly be preferred instead of recursive mutexes in new code anyway. -BEGIN VERIFY SCRIPT- set -x set -e ren() { git grep -l $1 | xargs sed -i s/$1/$2/; } ren CCriticalBlock UniqueLock ren CWaitableCriticalSection Mutex ren CConditionVariable std::condition_variable ren cs_GenesisWait g_genesis_wait_mutex ren condvar_GenesisWait g_genesis_wait_cv perl -0777 -pi -e 's/.*typedef.*condition_variable.*\n\n?//g' src/sync.h -END VERIFY SCRIPT-
* Merge #11640: Make LOCK, LOCK2, TRY_LOCK work with CWaitableCriticalSectionWladimir J. van der Laan2018-08-311-48/+57
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | 9c4dc597ddc66acfd58a945a5ab11f833731abba Use LOCK macros for non-recursive locks (Russell Yanofsky) 1382913e61f5db6ba849b1e261e8aefcd5a1ae68 Make LOCK, LOCK2, TRY_LOCK work with CWaitableCriticalSection (Russell Yanofsky) ba1f095aadf29bddb0bd8176d2e0b908f92a5623 MOVEONLY Move AnnotatedMixin declaration (Russell Yanofsky) 41b88e93375d57db12da923f45f87b9a2db8e730 Add unit test for DEBUG_LOCKORDER code (Russell Yanofsky) Pull request description: Make LOCK macros work with non-recursive mutexes, and use wherever possible for better deadlock detection. Also add unit test for DEBUG_LOCKORDER code. Tree-SHA512: 64ef209307f28ecd0813a283f15c6406138c6ffe7f6cbbd084161044db60e2c099a7d0d2edcd1c5e7770a115e9b931b486e86c9a777bdc96d2e8a9f4dc192942
| * Use LOCK macros for non-recursive locksRussell Yanofsky2018-08-031-3/+0
| | | | | | | | Instead of std::unique_lock.
| * Make LOCK, LOCK2, TRY_LOCK work with CWaitableCriticalSectionRussell Yanofsky2018-08-031-28/+33
| | | | | | | | | | | | | | | | They should also work with any other mutex type which std::unique_lock supports. There is no change in behavior for current code that calls these macros with CCriticalSection mutexes.
| * MOVEONLY Move AnnotatedMixin declarationRussell Yanofsky2018-08-031-24/+24
| | | | | | | | | | Move AnnotatedMixin closer to where it's used, and after the DEBUG_LOCKORDER function declarations so it can call them.
| * Add unit test for DEBUG_LOCKORDER codeRussell Yanofsky2018-08-031-0/+7
| |
* | Update copyright headers to 2018DrahtBot2018-07-271-1/+1
|/
* Annotate AssertLockHeld() with ASSERT_CAPABILITY() for thread safety analysisJesse Cohen2018-07-251-2/+2
|
* Increment MIT Licence copyright header year on files modified in 2017Akira Takizawa2018-01-031-1/+1
|
* Switched sync.{cpp,h} to std threading primitives.Thomas Snider2017-11-181-10/+6
|
* scripted-diff: Replace #include "" with #include <> (ryanofsky)MeshCollider2017-11-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -BEGIN VERIFY SCRIPT- for f in \ src/*.cpp \ src/*.h \ src/bench/*.cpp \ src/bench/*.h \ src/compat/*.cpp \ src/compat/*.h \ src/consensus/*.cpp \ src/consensus/*.h \ src/crypto/*.cpp \ src/crypto/*.h \ src/crypto/ctaes/*.h \ src/policy/*.cpp \ src/policy/*.h \ src/primitives/*.cpp \ src/primitives/*.h \ src/qt/*.cpp \ src/qt/*.h \ src/qt/test/*.cpp \ src/qt/test/*.h \ src/rpc/*.cpp \ src/rpc/*.h \ src/script/*.cpp \ src/script/*.h \ src/support/*.cpp \ src/support/*.h \ src/support/allocators/*.h \ src/test/*.cpp \ src/test/*.h \ src/wallet/*.cpp \ src/wallet/*.h \ src/wallet/test/*.cpp \ src/wallet/test/*.h \ src/zmq/*.cpp \ src/zmq/*.h do base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f done -END VERIFY SCRIPT-
* Merge #10286: Call wallet notify callbacks in scheduler thread (without cs_main)Wladimir J. van der Laan2017-11-151-0/+3
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 89f0312 Remove redundant pwallet nullptr check (Matt Corallo) c4784b5 Add a dev notes document describing the new wallet RPC blocking (Matt Corallo) 3ea8b75 Give ZMQ consistent order with UpdatedBlockTip on scheduler thread (Matt Corallo) cb06edf Fix wallet RPC race by waiting for callbacks in sendrawtransaction (Matt Corallo) e545ded Also call other wallet notify callbacks in scheduler thread (Matt Corallo) 17220d6 Use callbacks to cache whether wallet transactions are in mempool (Matt Corallo) 5d67a78 Add calls to CWallet::BlockUntilSyncedToCurrentChain() in RPCs (Matt Corallo) 5ee3172 Add CWallet::BlockUntilSyncedToCurrentChain() (Matt Corallo) 0b2f42d Add CallFunctionInQueue to wait on validation interface queue drain (Matt Corallo) 2b4b345 Add ability to assert a lock is not held in DEBUG_LOCKORDER (Matt Corallo) 0343676 Call TransactionRemovedFromMempool in the CScheduler thread (Matt Corallo) a7d3936 Add a CValidationInterface::TransactionRemovedFromMempool (Matt Corallo) Pull request description: Based on #10179, this effectively reverts #9583, regaining most of the original speedups of #7946. This concludes the work of #9725, #10178, and #10179. See individual commit messages for more information. Tree-SHA512: eead4809b0a75d1fb33b0765174ff52c972e45040635e38cf3686cef310859c1e6b3c00e7186cbd17374c6ae547bfbd6c1718fe36f26c76ba8a8b052d6ed7bc9
| * Add ability to assert a lock is not held in DEBUG_LOCKORDERMatt Corallo2017-10-131-0/+3
| |
* | Fix -Wthread-safety-analysis warnings. Change the sync.h primitives to std ↵Matt Corallo2017-11-061-22/+24
|/ | | | | | | | | | | | | | | | from boost. Commit 1. This code was written by @TheBlueMatt in the following branch: * https://github.com/TheBlueMatt/bitcoin/commits/2017-08-test-10923 This commit message was written by me (@practicalswift) who also squashed @TheBlueMatt's commits into one and tried to summarize the changes made. Commit 2. Remove boost include. Remove boost mentions in comments.
* Declare single-argument (non-converting) constructors "explicit"practicalswift2017-08-161-2/+2
| | | | In order to avoid unintended implicit conversions.
* Merge #9964: Add const to methods that do not modify the object for which it ↵MarcoFalke2017-08-161-1/+1
|\ | | | | | | | | | | | | | | | | | | is called 6e8c48dc5 Add const to methods that do not modify the object for which it is called (practicalswift) Pull request description: Tree-SHA512: a6888111ba16fb796e320e60806e1a77d36f545989b5405dc7319992291800109eab0b8e8c286b784778f41f1ff5289e7cb6b4afd7aec77f385fbcafc02cffc1
| * Add const to methods that do not modify the object for which it is calledpracticalswift2017-07-251-1/+1
| |
* | scripted-diff: Use the C++11 keyword nullptr to denote the pointer literal ↵practicalswift2017-08-071-1/+1
|/ | | | | | | | | | | | | instead of the macro NULL -BEGIN VERIFY SCRIPT- sed -i 's/\<NULL\>/nullptr/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h src/qt/*/*.cpp src/qt/*/*.h src/wallet/*/*.cpp src/wallet/*/*.h src/support/allocators/*.h sed -i 's/Prefer nullptr, otherwise SAFECOOKIE./Prefer NULL, otherwise SAFECOOKIE./g' src/torcontrol.cpp sed -i 's/tor: Using nullptr authentication/tor: Using NULL authentication/g' src/torcontrol.cpp sed -i 's/METHODS=nullptr/METHODS=NULL/g' src/test/torcontrol_tests.cpp src/torcontrol.cpp sed -i 's/nullptr certificates/NULL certificates/g' src/qt/paymentserver.cpp sed -i 's/"nullptr"/"NULL"/g' src/torcontrol.cpp src/test/torcontrol_tests.cpp -END VERIFY SCRIPT-
* Remove unused Boost includespracticalswift2017-06-091-1/+0
|
* Remove unused codepracticalswift2017-03-171-1/+0
|
* Break addnode out from the outbound connection limits.Gregory Maxwell2017-01-051-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously addnodes were in competition with outbound connections for access to the eight outbound slots. One result of this is that frequently a node with several addnode configured peers would end up connected to none of them, because while the addnode loop was in its two minute sleep the automatic connection logic would fill any free slots with random peers. This is particularly unwelcome to users trying to maintain links to specific nodes for fast block relay or purposes. Another result is that a group of nine or more nodes which are have addnode configured towards each other can become partitioned from the public network. This commit introduces a new limit of eight connections just for addnode peers which is not subject to any of the other connection limitations (including maxconnections). The choice of eight is sufficient so that under no condition would a user find themselves connected to fewer addnoded peers than previously. It is also low enough that users who are confused about the significance of more connections and have gotten too copy-and-paste happy will not consume more than twice the slot usage of a typical user. Any additional load on the network resulting from this will likely be offset by a reduction in users applying even more wasteful workaround for the prior behavior. The retry delays are reduced to avoid nodes sitting around without their added peers up, but are still sufficient to prevent overly aggressive repeated connections. The reduced delays also make the system much more responsive to the addnode RPC. Ban-disconnects are also exempted for peers added via addnode since the outbound addnode logic ignores bans. Previously it would ban an addnode then immediately reconnect to it. A minor change was also made to CSemaphoreGrant so that it is possible to re-acquire via an object whos grant was moved.
* Increment MIT Licence copyright header year on files modified in 2016isle29832016-12-311-1/+1
| | | | | | Edited via: $ contrib/devtools/copyright_header.py update .
* Do not shadow LOCK's criticalblock variable for LOCK inside LOCKPavel Janík2016-08-061-1/+4
|
* Clean up lockorder data of destroyed mutexesPieter Wuille2016-04-101-12/+21
| | | | | | | | | | | | | | | The lockorder potential deadlock detection works by remembering for each lock A that is acquired while holding another B the pair (A,B), and triggering a warning when (B,A) already exists in the table. A and B in the above text are represented by pointers to the CCriticalSection object that is acquired. This does mean however that we need to clean up the table entries that refer to any critical section which is destroyed, as it memory address can potentially be used for another unrelated lock in the future. Implement this clean up by remembering not only the pairs in forward direction, but also backward direction. This allows for fast iteration over all pairs that use a deleted CCriticalSection in either the first or the second position.
* Bump copyright headers to 2015MarcoFalke2015-12-131-1/+1
|
* typofixes (found by misspell_fixer)Veres Lajos2015-08-101-1/+1
|
* locking: teach Clang's -Wthread-safety to cope with our scoped lock macrosCory Fields2015-06-161-4/+4
| | | | | | | | This allows us to use function/variable/class attributes to specify locking requisites, allowing problems to be detected during static analysis. This works perfectly with newer Clang versions (tested with 3.3-3.7). For older versions (tested 3.2), it compiles fine but spews lots of false-positives.
* [Trivial] format sync.hPhilip Kaufmann2015-04-201-14/+9
|
* Removed main.h dependency from rpcserver.cppEric Lombrozo2015-01-281-0/+11
| | | | | | | | Rebased by @laanwj: - update for RPC methods added since 84d13ee: setmocktime, invalidateblock, reconsiderblock. Only the first, setmocktime, required a change, the other two are thread safe.
* Added "Core" to copyright headerssandakersmann2014-12-191-1/+1
| | | | | Github-Pull: #5494 Rebased-From: 15de949bb9277e442302bdd8dee299a8d6deee60
* Remove references to X11 licenceMichael Ford2014-12-161-1/+1
|
* Apply clang-format on some infrequently-updated filesPieter Wuille2014-09-191-30/+40
|
* add missing header end commentsPhilip Kaufmann2014-08-281-1/+1
| | | | | | - ensures a consistent usage in header files - also add a blank line after the copyright header where missing - also remove orphan new-lines at the end of some files
* getblocktemplate: longpolling supportLuke Dashjr2014-07-111-0/+3
|
* Use mutex pointer instead of name for AssertLockHeldWladimir J. van der Laan2013-12-191-2/+3
| | | | | This makes it useable for non-global locks such as the wallet and keystore locks.
* mutex debugging routines: LocksHeld() and AssertLockHeld()Gavin Andresen2013-11-291-0/+3
|
* Cleanup code using forward declarations.Brandon Dahler2013-11-101-3/+5
| | | | | | | | | Use misc methods of avoiding unnecesary header includes. Replace int typedefs with int##_t from stdint.h. Replace PRI64[xdu] with PRI[xdu]64 from inttypes.h. Normalize QT_VERSION ifs where possible. Resolve some indirect dependencies as direct ones. Remove extern declarations from .cpp files.
* Bump Year Number to 2013super32013-10-201-1/+1
|
* Added comments to sync.h to make it easier to understand the macrosEric Lombrozo2013-06-251-0/+42
|
* Merge pull request #2003 from alexanderkjeldaas/documented-locking-part-2Gavin Andresen2012-12-121-2/+23
|\ | | | | Documented locking part 1+2
| * o Added AnnotatedMixin which adds locking annotations to the mutexAlexander Kjeldaas2012-11-111-2/+23
| | | | | | | | API, compatible with clang's -Wthread-safety
* | Simplify CMutexLockAlexander Kjeldaas2012-11-141-30/+10
|/ | | | | | | | | | | | | | | | | | | | | | | | | o Remove unused Leave and GetLock functions o Make Enter and TryEnter private. o Simplify Enter and TryEnter. boost::unique_lock doesn't really know whether the mutex it wraps is locked or not when the defer_lock option is used. The boost::recursive_mutex does not expose this information, so unique_lock only infers this knowledge. When taking the lock is defered, it (randomly) assumes that the lock is not taken. boost::unique_lock has the following definition: unique_lock(Mutex& m_,defer_lock_t): m(&m_),is_locked(false) {} bool owns_lock() const { return is_locked; } Thus it is a mistake to check owns_lock() in Enter and TryEnter - they will always return false.
* Update comment, we're no longer using boost::interprocess::scoped_lockWladimir J. van der Laan2012-09-251-1/+1
|
* Fix DEBUG_LOCKCONTENTIONMatt Corallo2012-06-051-2/+5
|
* Merge pull request #1354 from fanquake/masterPieter Wuille2012-05-201-1/+1
|\ | | | | Update Header Licenses
| * Update License in File HeadersFordy2012-05-181-1/+1
| | | | | | | | | | | | I originally created a pull to replace the "COPYING" in crypter.cpp and crypter.h, but it turned out that COPYING was actually the correct file.
* | Use boost::thread locking instead of interprocessPieter Wuille2012-05-181-42/+35
|/
* Split synchronization mechanisms from util.{h,cpp}Pieter Wuille2012-05-111-0/+216