Add TEMP_FAILURE_RETRY to libsuspend.
In testing, I observed one instance of a call failing due to a signal sent to the process. This could happen at various times so it's better to be safe than sorry. Bug: 20534809 Change-Id: I42242087300d8b840a50aec34aa6b2e1507cab50
This commit is contained in:
parent
a51d8b9a1c
commit
0446e16f53
|
@ -40,7 +40,7 @@ static int autosuspend_autosleep_enable(void)
|
|||
|
||||
ALOGV("autosuspend_autosleep_enable\n");
|
||||
|
||||
ret = write(autosleep_fd, sleep_state, strlen(sleep_state));
|
||||
ret = TEMP_FAILURE_RETRY(write(autosleep_fd, sleep_state, strlen(sleep_state)));
|
||||
if (ret < 0) {
|
||||
strerror_r(errno, buf, sizeof(buf));
|
||||
ALOGE("Error writing to %s: %s\n", SYS_POWER_AUTOSLEEP, buf);
|
||||
|
@ -62,7 +62,7 @@ static int autosuspend_autosleep_disable(void)
|
|||
|
||||
ALOGV("autosuspend_autosleep_disable\n");
|
||||
|
||||
ret = write(autosleep_fd, on_state, strlen(on_state));
|
||||
ret = TEMP_FAILURE_RETRY(write(autosleep_fd, on_state, strlen(on_state)));
|
||||
if (ret < 0) {
|
||||
strerror_r(errno, buf, sizeof(buf));
|
||||
ALOGE("Error writing to %s: %s\n", SYS_POWER_AUTOSLEEP, buf);
|
||||
|
@ -86,7 +86,7 @@ struct autosuspend_ops *autosuspend_autosleep_init(void)
|
|||
{
|
||||
char buf[80];
|
||||
|
||||
autosleep_fd = open(SYS_POWER_AUTOSLEEP, O_WRONLY);
|
||||
autosleep_fd = TEMP_FAILURE_RETRY(open(SYS_POWER_AUTOSLEEP, O_WRONLY));
|
||||
if (autosleep_fd < 0) {
|
||||
strerror_r(errno, buf, sizeof(buf));
|
||||
ALOGE("Error opening %s: %s\n", SYS_POWER_AUTOSLEEP, buf);
|
||||
|
|
|
@ -49,11 +49,9 @@ int wait_for_fb_wake(void)
|
|||
{
|
||||
int err = 0;
|
||||
char buf;
|
||||
int fd = open(EARLYSUSPEND_WAIT_FOR_FB_WAKE, O_RDONLY, 0);
|
||||
int fd = TEMP_FAILURE_RETRY(open(EARLYSUSPEND_WAIT_FOR_FB_WAKE, O_RDONLY, 0));
|
||||
// if the file doesn't exist, the error will be caught in read() below
|
||||
do {
|
||||
err = read(fd, &buf, 1);
|
||||
} while (err < 0 && errno == EINTR);
|
||||
err = TEMP_FAILURE_RETRY(read(fd, &buf, 1));
|
||||
ALOGE_IF(err < 0,
|
||||
"*** ANDROID_WAIT_FOR_FB_WAKE failed (%s)", strerror(errno));
|
||||
close(fd);
|
||||
|
@ -64,11 +62,9 @@ static int wait_for_fb_sleep(void)
|
|||
{
|
||||
int err = 0;
|
||||
char buf;
|
||||
int fd = open(EARLYSUSPEND_WAIT_FOR_FB_SLEEP, O_RDONLY, 0);
|
||||
int fd = TEMP_FAILURE_RETRY(open(EARLYSUSPEND_WAIT_FOR_FB_SLEEP, O_RDONLY, 0));
|
||||
// if the file doesn't exist, the error will be caught in read() below
|
||||
do {
|
||||
err = read(fd, &buf, 1);
|
||||
} while (err < 0 && errno == EINTR);
|
||||
err = TEMP_FAILURE_RETRY(read(fd, &buf, 1));
|
||||
ALOGE_IF(err < 0,
|
||||
"*** ANDROID_WAIT_FOR_FB_SLEEP failed (%s)", strerror(errno));
|
||||
close(fd);
|
||||
|
@ -134,7 +130,7 @@ static int autosuspend_earlysuspend_disable(void)
|
|||
|
||||
ALOGV("autosuspend_earlysuspend_disable\n");
|
||||
|
||||
ret = write(sPowerStatefd, pwr_state_on, strlen(pwr_state_on));
|
||||
ret = TEMP_FAILURE_RETRY(write(sPowerStatefd, pwr_state_on, strlen(pwr_state_on)));
|
||||
if (ret < 0) {
|
||||
strerror_r(errno, buf, sizeof(buf));
|
||||
ALOGE("Error writing to %s: %s\n", EARLYSUSPEND_SYS_POWER_STATE, buf);
|
||||
|
@ -195,7 +191,7 @@ struct autosuspend_ops *autosuspend_earlysuspend_init(void)
|
|||
char buf[80];
|
||||
int ret;
|
||||
|
||||
sPowerStatefd = open(EARLYSUSPEND_SYS_POWER_STATE, O_RDWR);
|
||||
sPowerStatefd = TEMP_FAILURE_RETRY(open(EARLYSUSPEND_SYS_POWER_STATE, O_RDWR));
|
||||
|
||||
if (sPowerStatefd < 0) {
|
||||
strerror_r(errno, buf, sizeof(buf));
|
||||
|
@ -203,7 +199,7 @@ struct autosuspend_ops *autosuspend_earlysuspend_init(void)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
ret = write(sPowerStatefd, "on", 2);
|
||||
ret = TEMP_FAILURE_RETRY(write(sPowerStatefd, "on", 2));
|
||||
if (ret < 0) {
|
||||
strerror_r(errno, buf, sizeof(buf));
|
||||
ALOGW("Error writing 'on' to %s: %s\n", EARLYSUSPEND_SYS_POWER_STATE, buf);
|
||||
|
|
|
@ -51,7 +51,8 @@ static void *suspend_thread_func(void *arg __attribute__((unused)))
|
|||
usleep(100000);
|
||||
ALOGV("%s: read wakeup_count\n", __func__);
|
||||
lseek(wakeup_count_fd, 0, SEEK_SET);
|
||||
wakeup_count_len = read(wakeup_count_fd, wakeup_count, sizeof(wakeup_count));
|
||||
wakeup_count_len = TEMP_FAILURE_RETRY(read(wakeup_count_fd, wakeup_count,
|
||||
sizeof(wakeup_count)));
|
||||
if (wakeup_count_len < 0) {
|
||||
strerror_r(errno, buf, sizeof(buf));
|
||||
ALOGE("Error reading from %s: %s\n", SYS_POWER_WAKEUP_COUNT, buf);
|
||||
|
@ -72,13 +73,13 @@ static void *suspend_thread_func(void *arg __attribute__((unused)))
|
|||
}
|
||||
|
||||
ALOGV("%s: write %*s to wakeup_count\n", __func__, wakeup_count_len, wakeup_count);
|
||||
ret = write(wakeup_count_fd, wakeup_count, wakeup_count_len);
|
||||
ret = TEMP_FAILURE_RETRY(write(wakeup_count_fd, wakeup_count, wakeup_count_len));
|
||||
if (ret < 0) {
|
||||
strerror_r(errno, buf, sizeof(buf));
|
||||
ALOGE("Error writing to %s: %s\n", SYS_POWER_WAKEUP_COUNT, buf);
|
||||
} else {
|
||||
ALOGV("%s: write %s to %s\n", __func__, sleep_state, SYS_POWER_STATE);
|
||||
ret = write(state_fd, sleep_state, strlen(sleep_state));
|
||||
ret = TEMP_FAILURE_RETRY(write(state_fd, sleep_state, strlen(sleep_state)));
|
||||
if (ret < 0) {
|
||||
strerror_r(errno, buf, sizeof(buf));
|
||||
ALOGE("Error writing to %s: %s\n", SYS_POWER_STATE, buf);
|
||||
|
@ -157,14 +158,14 @@ struct autosuspend_ops *autosuspend_wakeup_count_init(void)
|
|||
int ret;
|
||||
char buf[80];
|
||||
|
||||
state_fd = open(SYS_POWER_STATE, O_RDWR);
|
||||
state_fd = TEMP_FAILURE_RETRY(open(SYS_POWER_STATE, O_RDWR));
|
||||
if (state_fd < 0) {
|
||||
strerror_r(errno, buf, sizeof(buf));
|
||||
ALOGE("Error opening %s: %s\n", SYS_POWER_STATE, buf);
|
||||
goto err_open_state;
|
||||
}
|
||||
|
||||
wakeup_count_fd = open(SYS_POWER_WAKEUP_COUNT, O_RDWR);
|
||||
wakeup_count_fd = TEMP_FAILURE_RETRY(open(SYS_POWER_WAKEUP_COUNT, O_RDWR));
|
||||
if (wakeup_count_fd < 0) {
|
||||
strerror_r(errno, buf, sizeof(buf));
|
||||
ALOGE("Error opening %s: %s\n", SYS_POWER_WAKEUP_COUNT, buf);
|
||||
|
|
Loading…
Reference in New Issue