Skip to content

Commit

Permalink
test: fixing interactions between waitFor and ignore_spurious_events (e…
Browse files Browse the repository at this point in the history
…nvoyproxy#4309)

Making sure if waitForHalfClose stops waiting due to the short waitFor timeout of 5ms, rather than a spurious event occurring, that the test continues waiting for half close.

Risk Level: low (test only)
Testing: tcp_proxy_integration_testx1000 test/integration:all x1
Docs Changes: n./a
Release Notes: n/a
Fixes envoyproxy#4031

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
  • Loading branch information
alyssawilk authored and htuch committed Sep 4, 2018
1 parent 69474b3 commit 7bc210e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/integration/fake_upstream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,13 @@ AssertionResult FakeConnectionBase::waitForHalfClose(bool ignore_spurious_events
if (std::chrono::steady_clock::now() >= end_time) {
return AssertionFailure() << "Timed out waiting for half close.";
}
connection_event_.waitFor(lock_, 5ms); // Safe since CondVar::waitFor won't throw.
Thread::CondVar::WaitStatus status = connection_event_.waitFor(lock_, 5ms);
// The default behavior of waitForHalfClose is to assume the test cleanly
// calls waitForData, waitForNewStream, etc. to handle all events on the
// connection. If the caller explicitly notes that other events should be
// ignored, continue looping until a disconnect is detected. Otherwise fall
// through and hit the assert below.
if (!ignore_spurious_events) {
if (status == Thread::CondVar::WaitStatus::NoTimeout && !ignore_spurious_events) {
break;
}
}
Expand Down

0 comments on commit 7bc210e

Please sign in to comment.