From f5a960a187ba8959596f6a324c2b5a05c1be9b35 Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Wed, 10 Aug 2016 17:57:01 -0700 Subject: [PATCH] debuggerd: remove useless timeout from wait_for_signal. The watchdog already handles things for us, so the timeout logic in wait_for_signal is pointless. Change-Id: Id81ad5f294068216b73e04c4e2ceca072ae1bbc0 --- debuggerd/debuggerd.cpp | 5 +++-- debuggerd/utility.cpp | 15 ++------------- debuggerd/utility.h | 2 +- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/debuggerd/debuggerd.cpp b/debuggerd/debuggerd.cpp index a82fd079e..0c18b9c58 100644 --- a/debuggerd/debuggerd.cpp +++ b/debuggerd/debuggerd.cpp @@ -459,9 +459,10 @@ static bool perform_dump(const debugger_request_t& request, int fd, int tombston return false; } - int total_sleep_time_usec = 0; while (true) { - int signal = wait_for_signal(request.tid, &total_sleep_time_usec); + // wait_for_signal waits for forever, but the watchdog process will kill us + // if it takes too long. + int signal = wait_for_signal(request.tid); switch (signal) { case -1: ALOGE("debuggerd: timed out waiting for signal"); diff --git a/debuggerd/utility.cpp b/debuggerd/utility.cpp index bd060954e..7fabf690b 100644 --- a/debuggerd/utility.cpp +++ b/debuggerd/utility.cpp @@ -31,9 +31,6 @@ #include #include -constexpr int SLEEP_TIME_USEC = 50000; // 0.05 seconds -constexpr int MAX_TOTAL_SLEEP_USEC = 10000000; // 10 seconds - // Whitelist output desired in the logcat output. bool is_allowed_in_logcat(enum logtype ltype) { if ((ltype == HEADER) @@ -74,10 +71,10 @@ void _LOG(log_t* log, enum logtype ltype, const char* fmt, ...) { } } -int wait_for_signal(pid_t tid, int* total_sleep_time_usec) { +int wait_for_signal(pid_t tid) { while (true) { int status; - pid_t n = TEMP_FAILURE_RETRY(waitpid(tid, &status, __WALL | WNOHANG)); + pid_t n = TEMP_FAILURE_RETRY(waitpid(tid, &status, __WALL)); if (n == -1) { ALOGE("waitpid failed: tid %d, %s", tid, strerror(errno)); return -1; @@ -91,14 +88,6 @@ int wait_for_signal(pid_t tid, int* total_sleep_time_usec) { return -1; } } - - if (*total_sleep_time_usec > MAX_TOTAL_SLEEP_USEC) { - ALOGE("timed out waiting for stop signal: tid=%d", tid); - return -1; - } - - usleep(SLEEP_TIME_USEC); - *total_sleep_time_usec += SLEEP_TIME_USEC; } } diff --git a/debuggerd/utility.h b/debuggerd/utility.h index cd01188c3..d820f0f91 100644 --- a/debuggerd/utility.h +++ b/debuggerd/utility.h @@ -77,7 +77,7 @@ enum logtype { void _LOG(log_t* log, logtype ltype, const char *fmt, ...) __attribute__ ((format(printf, 3, 4))); -int wait_for_signal(pid_t tid, int* total_sleep_time_usec); +int wait_for_signal(pid_t tid); void dump_memory(log_t* log, Backtrace* backtrace, uintptr_t addr, const char* fmt, ...);