[PATCH xserver] inputthread: Re-add fd to the inputThreadInfo->fds pollfd set when re-added

Keith Packard keithp at keithp.com
Fri Oct 14 20:46:47 UTC 2016


Mihail Konev <k.mvc at ya.ru> writes:

> 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);
>      }

Looks good to me.

Reviewed-by: Keith Packard <keithp at keithp.com>

-- 
-keith
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 800 bytes
Desc: not available
URL: <https://lists.x.org/archives/xorg-devel/attachments/20161014/40f6893e/attachment.sig>


More information about the xorg-devel mailing list