mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:50:18 +00:00
libhealthloop: Handle netlink receive buffer overflows am: 0cfcfac12d
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/3207758 Change-Id: Icf46f239d061c62339a23e7926820342b026f10a Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -57,14 +57,13 @@ int HealthLoop::RegisterEvent(int fd, BoundFunction func, EventWakeup wakeup) {
|
||||
EventHandler{this, fd, std::move(func)}))
|
||||
.get();
|
||||
|
||||
struct epoll_event ev;
|
||||
|
||||
ev.events = EPOLLIN;
|
||||
struct epoll_event ev = {
|
||||
.events = EPOLLIN | EPOLLERR,
|
||||
.data.ptr = reinterpret_cast<void*>(event_handler),
|
||||
};
|
||||
|
||||
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;
|
||||
@@ -119,9 +118,15 @@ void HealthLoop::PeriodicChores() {
|
||||
|
||||
// TODO(b/140330870): Use BPF instead.
|
||||
#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;
|
||||
|
||||
Reference in New Issue
Block a user