diff options
| author | Suhas Daftuar <[email protected]> | 2015-01-28 13:48:36 -0500 |
|---|---|---|
| committer | Suhas Daftuar <[email protected]> | 2015-02-03 08:53:08 -0500 |
| commit | cf008ac8c3c5d582562d88ad89020daef3e64dcb (patch) | |
| tree | 75c5c0bec467de682b340c39573dcecee0d95497 /src/checkqueue.h | |
| parent | Merge pull request #5700 (diff) | |
| download | discoin-cf008ac8c3c5d582562d88ad89020daef3e64dcb.tar.xz discoin-cf008ac8c3c5d582562d88ad89020daef3e64dcb.zip | |
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/checkqueue.h')
| -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 b8e2a17c7..7f6eae650 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); } } |