diff options
author | Suhas Daftuar <sdaftuar@gmail.com> | 2015-01-28 13:48:36 -0500 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-02-23 19:34:24 +0100 |
commit | d148f62e00612fdd9aa44aa1d891b03e131918c8 (patch) | |
tree | 6868c104f50517a1109d399035662bc343415271 /src | |
parent | 7f502be2598af1cbe5b04776985e0da9bcaebe21 (diff) | |
download | bitcoin-d148f62e00612fdd9aa44aa1d891b03e131918c8.tar.xz |
Acquire CCheckQueue's lock to avoid race condition
This fixes a potential race condition in the CCheckQueueControl constructor,
which was looking directly at data in CCheckQueue without acquiring its lock.
Remove the now-unnecessary friendship for CCheckQueueControl
Rebased-From: cf008ac8c3c5d582562d88ad89020daef3e64dcb
Github-Pull: #5721
Diffstat (limited to 'src')
-rw-r--r-- | src/checkqueue.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/checkqueue.h b/src/checkqueue.h index 2ee46a1210..b27f9e3d17 100644 --- a/src/checkqueue.h +++ b/src/checkqueue.h @@ -161,7 +161,12 @@ public: { } - friend class CCheckQueueControl<T>; + bool IsIdle() + { + boost::unique_lock<boost::mutex> lock(mutex); + return (nTotal == nIdle && nTodo == 0 && fAllOk == true); + } + }; /** @@ -180,9 +185,8 @@ public: { // passed queue is supposed to be unused, or NULL if (pqueue != NULL) { - assert(pqueue->nTotal == pqueue->nIdle); - assert(pqueue->nTodo == 0); - assert(pqueue->fAllOk == true); + bool isIdle = pqueue->IsIdle(); + assert(isIdle); } } |