Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Unified Diff: subprocess_unittest.cc

Issue 3005003: Don't wait for the http server forever. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: fix copyright Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: subprocess_unittest.cc
diff --git a/subprocess_unittest.cc b/subprocess_unittest.cc
index 86fba0148f93d8b75402354f02c5f573a0142c5b..65e56e6ca431d17cf40e218d3a1e9b15cc66343f 100644
--- a/subprocess_unittest.cc
+++ b/subprocess_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -67,6 +67,8 @@ gboolean StartAndCancelInRunLoop(gpointer data) {
cancel_test_data->spawned = true;
printf("spawned\n");
// Wait for server to be up and running
+ useconds_t total_wait_time = 0;
+ const useconds_t kMaxWaitTime = 3 * 1000000; // 3 seconds
for (;;) {
int status =
System(StringPrintf("wget -O /dev/null http://127.0.0.1:%d/foo",
@@ -76,7 +78,11 @@ gboolean StartAndCancelInRunLoop(gpointer data) {
<< "command failed to run or died abnormally";
if (0 == WEXITSTATUS(status))
break;
- usleep(100 * 1000); // 100 ms
+
+ const useconds_t kSleepTime = 100 * 1000; // 100ms
+ usleep(kSleepTime); // 100 ms
+ total_wait_time += kSleepTime;
+ CHECK_LT(total_wait_time, kMaxWaitTime);
}
Subprocess::Get().CancelExec(tag);
return FALSE;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698