Merge "Revert "libhealthloop: Handle netlink receive buffer overflows"" into main am: d9974eb049

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/3243781

Change-Id: I22cf936e717a94f86c09fe7bfc86d5c434441f06
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Bart Van Assche
2024-08-27 15:48:42 +00:00
committed by Automerger Merge Worker

View File

@@ -61,13 +61,14 @@ int HealthLoop::RegisterEvent(int fd, BoundFunction func, EventWakeup wakeup) {
EventHandler{this, fd, std::move(func)}))
.get();
struct epoll_event ev = {
.events = EPOLLIN | EPOLLERR,
.data.ptr = reinterpret_cast<void*>(event_handler),
};
struct epoll_event ev;
ev.events = EPOLLIN;
if (wakeup == EVENT_WAKEUP_FD) ev.events |= EPOLLWAKEUP;
ev.data.ptr = reinterpret_cast<void*>(event_handler);
if (epoll_ctl(epollfd_, EPOLL_CTL_ADD, fd, &ev) == -1) {
KLOG_ERROR(LOG_TAG, "epoll_ctl failed; errno=%d\n", errno);
return -1;
@@ -121,15 +122,9 @@ void HealthLoop::PeriodicChores() {
}
#define UEVENT_MSG_LEN 2048
void HealthLoop::UeventEvent(uint32_t epevents) {
void HealthLoop::UeventEvent(uint32_t /*epevents*/) {
// No need to lock because uevent_fd_ is guaranteed to be initialized.
if (epevents & EPOLLERR) {
// The netlink receive buffer overflowed.
ScheduleBatteryUpdate();
return;
}
char msg[UEVENT_MSG_LEN + 2];
char* cp;
int n;