Merge "uevent.c: avoid POLLERR infinite loop" into main am: cc5dc08c15

Original change: https://android-review.googlesource.com/c/platform/hardware/libhardware_legacy/+/2878224

Change-Id: I3262b82c9849723ce3930a2690a31157927e5c43
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Steven Moreland 2024-01-03 21:44:32 +00:00 committed by Automerger Merge Worker
commit 566a2901e9
2 changed files with 13 additions and 0 deletions

View file

@ -79,6 +79,7 @@ cc_library_shared {
shared_libs: [ shared_libs: [
"android.system.suspend-V1-ndk", "android.system.suspend-V1-ndk",
"libdl", "libdl",
"liblog",
], ],
header_libs: [ header_libs: [

View file

@ -16,6 +16,8 @@
#include <hardware_legacy/uevent.h> #include <hardware_legacy/uevent.h>
#include <log/log.h>
#include <malloc.h> #include <malloc.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
@ -94,6 +96,16 @@ int uevent_next_event(char* buffer, int buffer_length)
return count; return count;
} }
} }
if (nr > 0 && (fds.revents & POLLERR)) {
int error = 0;
socklen_t errlen = sizeof(error);
getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &errlen);
// see b/300009377, this used to be an infinite loop
// abort to try to recover
LOG_ALWAYS_FATAL("Uevent POLLERR: %s, on FD %d", strerror(error), fd);
}
} }
// won't get here // won't get here