summaryrefslogtreecommitdiffstats
path: root/tools/android
diff options
context:
space:
mode:
authorpliard@chromium.org <pliard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-26 17:08:51 +0000
committerpliard@chromium.org <pliard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-26 17:08:51 +0000
commit5f0e88b4a552c9fb5b953c4495b652d0559be977 (patch)
tree4b65d2affbe16404af92fd285f607305ddda3936 /tools/android
parent4a0999d8a0809438d7799e057e2c254d4c83dc20 (diff)
downloadchromium_src-5f0e88b4a552c9fb5b953c4495b652d0559be977.zip
chromium_src-5f0e88b4a552c9fb5b953c4495b652d0559be977.tar.gz
chromium_src-5f0e88b4a552c9fb5b953c4495b652d0559be977.tar.bz2
Increase timeout in Forwarder2's daemon.cc.
This is the timeout used to connect to the daemon's Unix Domain Socket. In case the daemon was just spawned it can easily take a few hundred milliseconds on the device before it binds the socket. The same timeout is now also used when killing the daemon. Review URL: https://chromiumcodereview.appspot.com/11418151 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169439 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/android')
-rw-r--r--tools/android/forwarder2/daemon.cc15
1 files changed, 8 insertions, 7 deletions
diff --git a/tools/android/forwarder2/daemon.cc b/tools/android/forwarder2/daemon.cc
index 4704e13..d90329e 100644
--- a/tools/android/forwarder2/daemon.cc
+++ b/tools/android/forwarder2/daemon.cc
@@ -34,6 +34,11 @@ namespace {
const int kBufferSize = 256;
+// Timeout constant used for polling when connecting to the daemon's Unix Domain
+// Socket and also when waiting for its death when it is killed.
+const int kNumTries = 100;
+const int kIdleTimeMSec = 20;
+
void InitLoggingForDaemon(const std::string& log_file) {
CHECK(
logging::InitLogging(
@@ -277,10 +282,8 @@ bool Daemon::SpawnIfNeeded() {
// Connect to the daemon's Unix Domain Socket.
bool failed = false;
if (!client_socket) {
- const int kConnectTries = 20;
- const int kConnectIdleTimeMSec = 10;
client_socket = ConnectToUnixDomainSocket(
- identifier_, kConnectTries, kConnectIdleTimeMSec, identifier_);
+ identifier_, kNumTries, kIdleTimeMSec, identifier_);
if (!client_socket) {
LOG(ERROR) << "Could not connect to daemon's Unix Daemon socket";
failed = true;
@@ -324,9 +327,7 @@ bool Daemon::Kill() {
// lock on the PID file when it exits.
// TODO(pliard): Consider using a mutex + condition in shared memory to avoid
// polling.
- const int kTries = 20;
- const int kIdleTimeMS = 50;
- for (int i = 0; i < kTries; ++i) {
+ for (int i = 0; i < kNumTries; ++i) {
pid_t current_lock_owner_pid;
if (!GetFileLockOwnerPid(pid_file_fd, &current_lock_owner_pid))
return false;
@@ -341,7 +342,7 @@ bool Daemon::Kill() {
<< current_lock_owner_pid << ") seems to be running now.";
return true;
}
- usleep(kIdleTimeMS * 1000);
+ usleep(kIdleTimeMSec * 1000);
}
LOG(ERROR) << "Timed out while killing daemon. "
"It might still be tearing down.";