lmkd: fix handling of EPOLLHUP for pidfd

Recent kernel change [1] cause pidfd_wait() to receive EPOLLHUP when the
task exits. Current LMKD implementation expects to receive EPOLLHUP only
when socket connection gets dropped, therefore it gets confused by this
new kernel behavior. Adjust LMKD handling of EPOLLHUP to detect the case
when this event is generated by pidfd.

[1] https://lore.kernel.org/all/20240202131226.GA26018@redhat.com/

Bug: 352286227
Change-Id: Ibcf349ee3cc73551541d64975f0292d53c41d5c2
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
This commit is contained in:
Suren Baghdasaryan 2024-09-11 10:03:34 -07:00
parent 1683221f0d
commit 667fdbfe92
1 changed files with 8 additions and 4 deletions

View File

@ -3911,11 +3911,15 @@ static void mainloop(void) {
*/ */
for (i = 0, evt = &events[0]; i < nevents; ++i, evt++) { for (i = 0, evt = &events[0]; i < nevents; ++i, evt++) {
if ((evt->events & EPOLLHUP) && evt->data.ptr) { if ((evt->events & EPOLLHUP) && evt->data.ptr) {
ALOGI("lmkd data connection dropped");
handler_info = (struct event_handler_info*)evt->data.ptr; handler_info = (struct event_handler_info*)evt->data.ptr;
watchdog.start(); if (handler_info->handler == kill_done_handler) {
ctrl_data_close(handler_info->data); call_handler(handler_info, &poll_params, evt->events);
watchdog.stop(); } else {
ALOGI("lmkd data connection dropped");
watchdog.start();
ctrl_data_close(handler_info->data);
watchdog.stop();
}
} }
} }