[PATCH] inputthread: Fix inputthread not listening if a fd gets re-added immediately after removal

Hans de Goede hdegoede at redhat.com
Wed Oct 5 12:45:20 UTC 2016


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 at 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



More information about the xorg-devel mailing list