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

Side by Side Diff: net/test/local_test_server_posix.cc

Issue 11784004: Make net/test/test_server correctly report timeouts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/test/local_test_server.h" 5 #include "net/test/local_test_server.h"
6 6
7 #include <poll.h> 7 #include <poll.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 base::Time previous_time = base::Time::Now(); 63 base::Time previous_time = base::Time::Now();
64 while (bytes_read < bytes_max) { 64 while (bytes_read < bytes_max) {
65 struct pollfd poll_fds[1]; 65 struct pollfd poll_fds[1];
66 66
67 poll_fds[0].fd = fd; 67 poll_fds[0].fd = fd;
68 poll_fds[0].events = POLLIN | POLLPRI; 68 poll_fds[0].events = POLLIN | POLLPRI;
69 poll_fds[0].revents = 0; 69 poll_fds[0].revents = 0;
70 70
71 int rv = HANDLE_EINTR(poll(poll_fds, 1, 71 int rv = HANDLE_EINTR(poll(poll_fds, 1,
72 remaining_time->InMilliseconds())); 72 remaining_time->InMilliseconds()));
73 if (rv != 1) { 73 if (rv == 0) {
74 PLOG(ERROR) << "poll() failed for child file descriptor"; 74 LOG(ERROR) << "poll() timed out; bytes_read=" << bytes_read;
75 return false;
76 } else if (rv < 0) {
77 PLOG(ERROR) << "poll() failed for child file descriptor; bytes_read="
78 << bytes_read;
75 return false; 79 return false;
76 } 80 }
77 81
78 base::Time current_time = base::Time::Now(); 82 base::Time current_time = base::Time::Now();
79 base::TimeDelta elapsed_time_cycle = current_time - previous_time; 83 base::TimeDelta elapsed_time_cycle = current_time - previous_time;
80 DCHECK_GE(elapsed_time_cycle.InMilliseconds(), 0); 84 DCHECK_GE(elapsed_time_cycle.InMilliseconds(), 0);
81 *remaining_time -= elapsed_time_cycle; 85 *remaining_time -= elapsed_time_cycle;
82 previous_time = current_time; 86 previous_time = current_time;
83 87
84 ssize_t num_bytes = HANDLE_EINTR(read(fd, buffer + bytes_read, 88 ssize_t num_bytes = HANDLE_EINTR(read(fd, buffer + bytes_read,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 167
164 if (!ParseServerData(server_data)) { 168 if (!ParseServerData(server_data)) {
165 LOG(ERROR) << "Could not parse server_data: " << server_data; 169 LOG(ERROR) << "Could not parse server_data: " << server_data;
166 return false; 170 return false;
167 } 171 }
168 172
169 return true; 173 return true;
170 } 174 }
171 175
172 } // namespace net 176 } // namespace net
OLDNEW
« 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