diff options
author | Suhas Daftuar <sdaftuar@gmail.com> | 2015-01-28 13:48:36 -0500 |
---|---|---|
committer | Suhas Daftuar <sdaftuar@gmail.com> | 2015-02-03 08:53:08 -0500 |
commit | cf008ac8c3c5d582562d88ad89020daef3e64dcb (patch) | |
tree | 75c5c0bec467de682b340c39573dcecee0d95497 /src | |
parent | b6acd4563d3b96b244e61b87b9f08c0eb61ecaa6 (diff) |
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
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 b8e2a17c76..7f6eae6509 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); } } |