Blob Blame History Raw
From 909cc5e8d1a51184259803ca66a1fc352c547e02 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Wed, 5 Oct 2016 14:40:00 +0200
Subject: [PATCH 3/7] inputthread: Fix inputthread not listening if a fd gets
 re-added immediately after removal

When a fd is removed dev->state gets set to device_state_removed,
if the fd then gets re-added before InputThreadDoWork() deals with
the removal, the InputThreadDevice struct gets reused, but its
state would stay device_state_removed, so it would still get removed
on the first InputThreadDoWork() run, resulting in a non functioning
input device.

This commit fixes this by (re-)setting dev->state to device_state_running
when a InputThreadDevice struct gets reused.

This fixes input devices sometimes no longer working after a vt-switch.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 os/inputthread.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/os/inputthread.c b/os/inputthread.c
index 6aa0a9c..ab1559f 100644
--- a/os/inputthread.c
+++ b/os/inputthread.c
@@ -206,6 +206,8 @@ InputThreadRegisterDev(int fd,
     if (dev) {
         dev->readInputProc = readInputProc;
         dev->readInputArgs = readInputArgs;
+        /* Override possible unhandled state == device_state_removed */
+        dev->state = device_state_running;
     } else {
         dev = calloc(1, sizeof(InputThreadDevice));
         if (dev == NULL) {
-- 
2.9.3