From 2fa9e939581d944f0204291c53356d6b8c3a938f Mon Sep 17 00:00:00 2001 From: Paul Lawrence Date: Fri, 12 Jun 2015 13:06:21 -0700 Subject: Retry polling to prevent failures Change-Id: I182ee7f70c5a96bbcdb0fc9e35df67c45a937757 --- ext4_utils/ext4_crypt_init_extensions.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ext4_utils/ext4_crypt_init_extensions.cpp b/ext4_utils/ext4_crypt_init_extensions.cpp index 7ae076a3..3fb04b98 100644 --- a/ext4_utils/ext4_crypt_init_extensions.cpp +++ b/ext4_utils/ext4_crypt_init_extensions.cpp @@ -60,18 +60,19 @@ static std::string vold_command(std::string const& command) struct pollfd poll_sock = {sock, POLLIN, 0}; - int rc = poll(&poll_sock, 1, vold_command_timeout_ms); + int rc = TEMP_FAILURE_RETRY(poll(&poll_sock, 1, vold_command_timeout_ms)); if (rc < 0) { KLOG_ERROR(TAG, "Error in poll %s\n", strerror(errno)); return ""; } + if (!(poll_sock.revents & POLLIN)) { KLOG_ERROR(TAG, "Timeout\n"); return ""; } char buffer[4096]; memset(buffer, 0, sizeof(buffer)); - rc = read(sock, buffer, sizeof(buffer)); + rc = TEMP_FAILURE_RETRY(read(sock, buffer, sizeof(buffer))); if (rc <= 0) { if (rc == 0) { KLOG_ERROR(TAG, "Lost connection to Vold - did it crash?\n"); -- cgit v1.2.3