From edad2bf9b60e8c5513f6a04bae44fe267ada4ae0 Mon Sep 17 00:00:00 2001 From: Tom Cherry Date: Wed, 13 Nov 2019 07:20:11 -0800 Subject: [PATCH] Use PLOG and TEMP_FAILURE_RETRY for uevent socket errors Use TEMP_FAILURE_RETRY() for recvmsg() to prevent failing unnecessarily from EINTR. Use PLOG(ERROR) in ueventd to display the actual error if reading from the uevent socket does fail. Test: build Change-Id: I64a22698ce6ffc7573f75b57803551c7b6940e30 --- init/uevent_listener.cpp | 2 +- libcutils/uevent.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/init/uevent_listener.cpp b/init/uevent_listener.cpp index 416d942d6..d8d9b36ff 100644 --- a/init/uevent_listener.cpp +++ b/init/uevent_listener.cpp @@ -100,7 +100,7 @@ bool UeventListener::ReadUevent(Uevent* uevent) const { int n = uevent_kernel_multicast_recv(device_fd_, msg, UEVENT_MSG_LEN); if (n <= 0) { if (errno != EAGAIN && errno != EWOULDBLOCK) { - LOG(ERROR) << "Error reading from Uevent Fd"; + PLOG(ERROR) << "Error reading from Uevent Fd"; } return false; } diff --git a/libcutils/uevent.cpp b/libcutils/uevent.cpp index 721de7c47..bf244d2c7 100644 --- a/libcutils/uevent.cpp +++ b/libcutils/uevent.cpp @@ -60,7 +60,7 @@ ssize_t uevent_kernel_recv(int socket, void* buffer, size_t length, bool require struct ucred* cred; *uid = -1; - ssize_t n = recvmsg(socket, &hdr, 0); + ssize_t n = TEMP_FAILURE_RETRY(recvmsg(socket, &hdr, 0)); if (n <= 0) { return n; }