system/corennnnn
Revisión | 509f099e1dc19199c125ccc2c5ba3d1bf16559fa (tree) |
---|---|
Tiempo | 2016-10-19 03:40:29 |
Autor | Tim Murray <timmurray@goog...> |
Commiter | gitbuildkicker |
Revert "libsuspend: move to exponential backoff"
This reverts commit fb896944b6a78d951c8442b444af860a28117e5c.
bug 32180327
Change-Id: Ic26bdffac6c56b102348f5393e6eb5d895960d7e
(cherry picked from commit 23c8bab0243bc6e7be8b95702c262c354009d56a)
@@ -21,7 +21,6 @@ | ||
21 | 21 | #include <stddef.h> |
22 | 22 | #include <stdbool.h> |
23 | 23 | #include <string.h> |
24 | -#include <sys/param.h> | |
25 | 24 | #include <sys/stat.h> |
26 | 25 | #include <sys/types.h> |
27 | 26 | #include <unistd.h> |
@@ -35,24 +34,12 @@ | ||
35 | 34 | #define SYS_POWER_STATE "/sys/power/state" |
36 | 35 | #define SYS_POWER_WAKEUP_COUNT "/sys/power/wakeup_count" |
37 | 36 | |
38 | -#define BASE_SLEEP_TIME 100000 | |
39 | - | |
40 | 37 | static int state_fd; |
41 | 38 | static int wakeup_count_fd; |
42 | 39 | static pthread_t suspend_thread; |
43 | 40 | static sem_t suspend_lockout; |
44 | 41 | static const char *sleep_state = "mem"; |
45 | 42 | static void (*wakeup_func)(bool success) = NULL; |
46 | -static int sleep_time = BASE_SLEEP_TIME; | |
47 | - | |
48 | -static void update_sleep_time(bool success) { | |
49 | - if (success) { | |
50 | - sleep_time = BASE_SLEEP_TIME; | |
51 | - return; | |
52 | - } | |
53 | - // double sleep time after each failure up to one minute | |
54 | - sleep_time = MIN(sleep_time * 2, 60000000); | |
55 | -} | |
56 | 43 | |
57 | 44 | static void *suspend_thread_func(void *arg __attribute__((unused))) |
58 | 45 | { |
@@ -60,12 +47,10 @@ static void *suspend_thread_func(void *arg __attribute__((unused))) | ||
60 | 47 | char wakeup_count[20]; |
61 | 48 | int wakeup_count_len; |
62 | 49 | int ret; |
63 | - bool success = true; | |
50 | + bool success; | |
64 | 51 | |
65 | 52 | while (1) { |
66 | - update_sleep_time(success); | |
67 | - usleep(sleep_time); | |
68 | - success = false; | |
53 | + usleep(100000); | |
69 | 54 | ALOGV("%s: read wakeup_count\n", __func__); |
70 | 55 | lseek(wakeup_count_fd, 0, SEEK_SET); |
71 | 56 | wakeup_count_len = TEMP_FAILURE_RETRY(read(wakeup_count_fd, wakeup_count, |
@@ -89,6 +74,7 @@ static void *suspend_thread_func(void *arg __attribute__((unused))) | ||
89 | 74 | continue; |
90 | 75 | } |
91 | 76 | |
77 | + success = true; | |
92 | 78 | ALOGV("%s: write %*s to wakeup_count\n", __func__, wakeup_count_len, wakeup_count); |
93 | 79 | ret = TEMP_FAILURE_RETRY(write(wakeup_count_fd, wakeup_count, wakeup_count_len)); |
94 | 80 | if (ret < 0) { |
@@ -97,8 +83,8 @@ static void *suspend_thread_func(void *arg __attribute__((unused))) | ||
97 | 83 | } else { |
98 | 84 | ALOGV("%s: write %s to %s\n", __func__, sleep_state, SYS_POWER_STATE); |
99 | 85 | ret = TEMP_FAILURE_RETRY(write(state_fd, sleep_state, strlen(sleep_state))); |
100 | - if (ret >= 0) { | |
101 | - success = true; | |
86 | + if (ret < 0) { | |
87 | + success = false; | |
102 | 88 | } |
103 | 89 | void (*func)(bool success) = wakeup_func; |
104 | 90 | if (func != NULL) { |