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

Unified Diff: src/d8-posix.cc

Issue 63062: Timeout of os.system() in d8 was timing out too soon. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 8 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: src/d8-posix.cc
===================================================================
--- src/d8-posix.cc (revision 1674)
+++ src/d8-posix.cc (working copy)
@@ -105,17 +105,17 @@
// Returns false on timeout, true on data ready.
static bool WaitOnFD(int fd,
int read_timeout,
- int* total_timeout,
+ int total_timeout,
struct timeval& start_time) {
fd_set readfds, writefds, exceptfds;
struct timeval timeout;
- if (*total_timeout != -1) {
+ int gone = 0;
+ if (total_timeout != -1) {
struct timeval time_now;
gettimeofday(&time_now, NULL);
int seconds = time_now.tv_sec - start_time.tv_sec;
- int gone = seconds * 1000 + (time_now.tv_usec - start_time.tv_usec) / 1000;
- if (gone >= *total_timeout) return false;
- *total_timeout -= gone;
+ gone = seconds * 1000 + (time_now.tv_usec - start_time.tv_usec) / 1000;
+ if (gone >= total_timeout) return false;
}
FD_ZERO(&readfds);
FD_ZERO(&writefds);
@@ -123,8 +123,8 @@
FD_SET(fd, &readfds);
FD_SET(fd, &exceptfds);
if (read_timeout == -1 ||
- (*total_timeout != -1 && *total_timeout < read_timeout)) {
- read_timeout = *total_timeout;
+ (total_timeout != -1 && total_timeout - gone < read_timeout)) {
+ read_timeout = total_timeout - gone;
}
timeout.tv_usec = (read_timeout % 1000) * 1000;
timeout.tv_sec = read_timeout / 1000;
@@ -306,7 +306,7 @@
static Handle<Value> GetStdout(int child_fd,
struct timeval& start_time,
int read_timeout,
- int* total_timeout) {
+ int total_timeout) {
Handle<String> accumulator = String::Empty();
const char* source = "function(a, b) { return a + b; }";
Handle<Value> cons_as_obj(Script::Compile(String::New(source))->Run());
@@ -332,7 +332,7 @@
read_timeout,
total_timeout,
start_time) ||
- (TimeIsOut(start_time, *total_timeout))) {
+ (TimeIsOut(start_time, total_timeout))) {
return ThrowException(String::New("Timed out waiting for output"));
}
continue;
@@ -502,7 +502,7 @@
Handle<Value> accumulator = GetStdout(stdout_fds[kReadFD],
start_time,
read_timeout,
- &total_timeout);
+ total_timeout);
if (accumulator->IsUndefined()) {
kill(pid, SIGINT); // On timeout, kill the subprocess.
return accumulator;
« 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