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

Unified Diff: net/test/test_server_posix.cc

Issue 3368012: Wait on a pipe for the test server to start up (Closed)
Patch Set: Sigh. Rebase onto trunk. Created 10 years, 3 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 | « net/test/test_server.cc ('k') | net/test/test_server_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/test/test_server_posix.cc
diff --git a/net/test/test_server_posix.cc b/net/test/test_server_posix.cc
index 7741d895f4d35dc683f5bc57637a77764755d008..262845c1749d79a945bd23b73baa102a1353aed3 100644
--- a/net/test/test_server_posix.cc
+++ b/net/test/test_server_posix.cc
@@ -32,8 +32,22 @@ bool TestServer::LaunchPython(const FilePath& testserver_path) {
if (type_ == TYPE_HTTPS_CLIENT_AUTH)
command_line.push_back("--ssl-client-auth");
- base::file_handle_mapping_vector no_mappings;
- if (!base::LaunchApp(command_line, no_mappings, false, &process_handle_)) {
+ int pipefd[2];
+ if (pipe(pipefd) != 0) {
+ PLOG(ERROR) << "Could not create pipe.";
+ return false;
+ }
+
+ // Save the read half. The write half is sent to the child.
+ child_fd_ = pipefd[0];
+ child_fd_closer_.reset(&child_fd_);
+ file_util::ScopedFD write_closer(&pipefd[1]);
+ base::file_handle_mapping_vector map_write_fd;
+ map_write_fd.push_back(std::make_pair(pipefd[1], pipefd[1]));
+
+ command_line.push_back("--startup-pipe=" + base::IntToString(pipefd[1]));
+
+ if (!base::LaunchApp(command_line, map_write_fd, false, &process_handle_)) {
LOG(ERROR) << "Failed to launch " << command_line[0] << " ...";
return false;
}
@@ -41,6 +55,14 @@ bool TestServer::LaunchPython(const FilePath& testserver_path) {
return true;
}
+bool TestServer::WaitToStart() {
+ char buf[8];
+ ssize_t n = HANDLE_EINTR(read(child_fd_, buf, sizeof(buf)));
+ // We don't need the FD anymore.
+ child_fd_closer_.reset(NULL);
+ return n > 0;
+}
+
bool TestServer::CheckCATrusted() {
return true;
}
« no previous file with comments | « net/test/test_server.cc ('k') | net/test/test_server_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698