summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-27 20:01:26 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-27 20:01:26 +0000
commit055134446549c4381c68d78e1f1d927bdd5a9ac9 (patch)
tree1cd7fad4134b9f229f362b118cb4675f1125572f
parent23bb5ca468d533c70da69e8db396468619413c73 (diff)
downloadchromium_src-055134446549c4381c68d78e1f1d927bdd5a9ac9.zip
chromium_src-055134446549c4381c68d78e1f1d927bdd5a9ac9.tar.gz
chromium_src-055134446549c4381c68d78e1f1d927bdd5a9ac9.tar.bz2
Linux: Kill the crash uploader process if it takes too long.
BUG=chromium-os:26357 TEST=see bug Review URL: https://chromiumcodereview.appspot.com/9460053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123790 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/breakpad_linux.cc26
1 files changed, 24 insertions, 2 deletions
diff --git a/chrome/app/breakpad_linux.cc b/chrome/app/breakpad_linux.cc
index 003bba8..4ab5f48 100644
--- a/chrome/app/breakpad_linux.cc
+++ b/chrome/app/breakpad_linux.cc
@@ -9,10 +9,12 @@
#include "chrome/app/breakpad_linux.h"
#include <fcntl.h>
+#include <poll.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
+#include <sys/wait.h>
#include <sys/uio.h>
#include <time.h>
#include <unistd.h>
@@ -686,8 +688,24 @@ void HandleCrashDump(const BreakpadInfo& info) {
if (wget_child > 0) {
IGNORE_RET(sys_close(fds[1]));
char id_buf[17]; // Crash report IDs are expected to be 16 chars.
- const int len = HANDLE_EINTR(sys_read(fds[0], id_buf,
- sizeof(id_buf) - 1));
+ ssize_t len = -1;
+ // Wget should finish in about 10 seconds. Add a few more 500 ms
+ // internals to account for process startup time.
+ for (size_t wait_count = 0; wait_count < 24; ++wait_count) {
+ struct kernel_pollfd poll_fd;
+ poll_fd.fd = fds[0];
+ poll_fd.events = POLLIN | POLLPRI | POLLERR;
+ int ret = sys_poll(&poll_fd, 1, 500);
+ if (ret < 0) {
+ // Error
+ break;
+ } else if (ret > 0) {
+ // There is data to read.
+ len = HANDLE_EINTR(sys_read(fds[0], id_buf, sizeof(id_buf) - 1));
+ break;
+ }
+ // ret == 0 -> timed out, continue waiting.
+ }
if (len > 0) {
// Write crash dump id to stderr.
id_buf[len] = 0;
@@ -716,6 +734,10 @@ void HandleCrashDump(const BreakpadInfo& info) {
}
}
}
+ if (sys_waitpid(wget_child, NULL, WNOHANG) == 0) {
+ // Wget process is still around, kill it.
+ sys_kill(wget_child, SIGKILL);
+ }
}
}