On Fri, Oct 14, 2016 at 02:38:00PM +1000, Peter Hutterer wrote:
> 
> This would be only a one-line change a bit above this hunk
> - if (old->fd == fd) {
> + if (old->fd == fd && dev->state != device_state_removed) {
> 
> The only drawback is that we rely on xorg_list_append() and that the new
> entry is later than the previous one so we have the same remove/add order as
> in your device_state_re_added handling below. That needs a comment
> but other than that we should get the same result?
> 
> Cheers,
>    Peter
> 

This works:

diff --git a/os/inputthread.c b/os/inputthread.c
index 6aa0a9ce6fb5..ddafa7fe8343 100644
--- a/os/inputthread.c
+++ b/os/inputthread.c
@@ -197,7 +197,7 @@ InputThreadRegisterDev(int fd,
 
     dev = NULL;
     xorg_list_for_each_entry(old, &inputThreadInfo->devs, node) {
-        if (old->fd == fd) {
+        if (old->fd == fd && old->state != device_state_removed) {
             dev = old;
             break;
         }
@@ -218,6 +218,9 @@ InputThreadRegisterDev(int fd,
         dev->readInputProc = readInputProc;
         dev->readInputArgs = readInputArgs;
         dev->state = device_state_added;
+
+        /* Do not prepend, so that any dev->state == device_state_removed
+         * with the same dev->fd get processed first. */
         xorg_list_append(&dev->node, &inputThreadInfo->devs);
     }
 
_______________________________________________
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to