From 667fdbfe923e5908de0ff9592db47cf768e3d6a8 Mon Sep 17 00:00:00 2001 From: Suren Baghdasaryan Date: Wed, 11 Sep 2024 10:03:34 -0700 Subject: [PATCH] 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 --- lmkd.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lmkd.cpp b/lmkd.cpp index 1030147..0c5479c 100644 --- a/lmkd.cpp +++ b/lmkd.cpp @@ -3911,11 +3911,15 @@ static void mainloop(void) { */ for (i = 0, evt = &events[0]; i < nevents; ++i, evt++) { if ((evt->events & EPOLLHUP) && evt->data.ptr) { - ALOGI("lmkd data connection dropped"); handler_info = (struct event_handler_info*)evt->data.ptr; - watchdog.start(); - ctrl_data_close(handler_info->data); - watchdog.stop(); + if (handler_info->handler == kill_done_handler) { + call_handler(handler_info, &poll_params, evt->events); + } else { + ALOGI("lmkd data connection dropped"); + watchdog.start(); + ctrl_data_close(handler_info->data); + watchdog.stop(); + } } }