Skip to content

Commit

Permalink
Avoid deadlock when /dev/input node is hung up.
Browse files Browse the repository at this point in the history
  • Loading branch information
Themaister committed Nov 18, 2023
1 parent 26172f7 commit 7f4c4d4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions application/input/input_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,14 @@ bool LinuxInputManager::poll()
{
for (int i = 0; i < ret; i++)
{
if (events[i].events & EPOLLIN)
auto &device = *static_cast<Device *>(events[i].data.ptr);
if ((events[i].events & (EPOLLHUP | EPOLLERR)) != 0)
{
remove_device(device.devnode.c_str());
}
else if ((events[i].events & EPOLLIN) != 0)
{
struct input_event input_events[32];
auto &device = *static_cast<Device *>(events[i].data.ptr);

ssize_t len;
while ((len = read(device.fd, input_events, sizeof(input_events))) > 0)
{
Expand Down

0 comments on commit 7f4c4d4

Please sign in to comment.