summaryrefslogtreecommitdiffstats
path: root/net/test/test_server_posix.cc
diff options
context:
space:
mode:
Diffstat (limited to 'net/test/test_server_posix.cc')
-rw-r--r--net/test/test_server_posix.cc39
1 files changed, 26 insertions, 13 deletions
diff --git a/net/test/test_server_posix.cc b/net/test/test_server_posix.cc
index 1456ac8..17b2631 100644
--- a/net/test/test_server_posix.cc
+++ b/net/test/test_server_posix.cc
@@ -110,24 +110,37 @@ bool TestServer::LaunchPython(const FilePath& testserver_path) {
}
bool TestServer::WaitToStart() {
- struct pollfd poll_fds[1];
-
- poll_fds[0].fd = child_fd_;
- poll_fds[0].events = POLLIN | POLLPRI;
- poll_fds[0].revents = 0;
+ uint16 port;
+ uint8* buffer = reinterpret_cast<uint8*>(&port);
+ ssize_t bytes_read = 0;
+ ssize_t bytes_max = sizeof(port);
+ while (bytes_read < bytes_max) {
+ struct pollfd poll_fds[1];
+
+ poll_fds[0].fd = child_fd_;
+ poll_fds[0].events = POLLIN | POLLPRI;
+ poll_fds[0].revents = 0;
+
+ int rv = HANDLE_EINTR(poll(poll_fds, 1,
+ TestTimeouts::action_max_timeout_ms()));
+ if (rv != 1) {
+ LOG(ERROR) << "Failed to poll for the child file descriptor.";
+ return false;
+ }
- int rv = HANDLE_EINTR(poll(poll_fds, 1,
- TestTimeouts::action_max_timeout_ms()));
- if (rv != 1) {
- LOG(ERROR) << "Failed to poll for the child file descriptor.";
- return false;
+ ssize_t num_bytes = HANDLE_EINTR(read(child_fd_, buffer + bytes_read,
+ bytes_max - bytes_read));
+ if (num_bytes <= 0)
+ break;
+ bytes_read += num_bytes;
}
- 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;
+ if (bytes_read < bytes_max)
+ return false;
+ host_port_pair_.set_port(port);
+ return true;
}
bool TestServer::CheckCATrusted() {