Skip to content

Commit fb6140b

Browse files
committed
Merge pull request #5721
cf008ac Acquire CCheckQueue's lock to avoid race condition (Suhas Daftuar)
2 parents 5d901d8 + cf008ac commit fb6140b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/checkqueue.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,12 @@ class CCheckQueue
161161
{
162162
}
163163

164-
friend class CCheckQueueControl<T>;
164+
bool IsIdle()
165+
{
166+
boost::unique_lock<boost::mutex> lock(mutex);
167+
return (nTotal == nIdle && nTodo == 0 && fAllOk == true);
168+
}
169+
165170
};
166171

167172
/**
@@ -180,9 +185,8 @@ class CCheckQueueControl
180185
{
181186
// passed queue is supposed to be unused, or NULL
182187
if (pqueue != NULL) {
183-
assert(pqueue->nTotal == pqueue->nIdle);
184-
assert(pqueue->nTodo == 0);
185-
assert(pqueue->fAllOk == true);
188+
bool isIdle = pqueue->IsIdle();
189+
assert(isIdle);
186190
}
187191
}
188192

0 commit comments

Comments
 (0)