Fix flaky MultiThreadProducerConsumerQueueStopTest

The main thread may run ahead of the closure thread. In this case,
Stop() could have been called before the first Push() call.

Change-Id: Ib6d94d451a8215fff572ea13f9567ba786d77fa5
This commit is contained in:
Kongqun Yang 2014-04-21 13:56:48 -07:00
parent a7c91ca7dd
commit 8df0e1ad0a
1 changed files with 5 additions and 1 deletions

View File

@ -311,7 +311,11 @@ class MultiThreadProducerConsumerQueueStopTest
int val = 0;
switch (op) {
case kPush:
CHECK_OK(queue_.Push(0, kInfiniteTimeout));
// The queue was setup with size 1. The first push will return STOPPED
// if Stop() has been called; otherwise it should return OK and the
// second push will block until Stop() being called.
status_ = queue_.Push(0, kInfiniteTimeout);
if (status_.ok())
status_ = queue_.Push(0, kInfiniteTimeout);
break;
case kPop: