[PATCH xf86-input-libinput] Drain the fd after opening

walter harms wharms at bfs.de
Wed Dec 16 14:14:28 PST 2015



Am 16.12.2015 01:15, schrieb Peter Hutterer:
> Make sure we discard any events that may have been enqueued before we
> re-opened the fd. Specifically, if we're using systemd-logind the fd remains
> open when we disable/enable the device, allowing events to queue up on the
> fd. These events are then replayed once the device is re-opened.
> 
> This only applies to a device being disabled via the protocol, on VT switch
> logind closes the fd and we don't see enqueued events.
> 
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>  src/xf86libinput.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/xf86libinput.c b/src/xf86libinput.c
> index ee2165a..2fde9ed 100644
> --- a/src/xf86libinput.c
> +++ b/src/xf86libinput.c
> @@ -1175,6 +1175,8 @@ open_restricted(const char *path, int flags, void *data)
>  	}
>  
>  	fd = xf86OpenSerial(pInfo->options);
> +	xf86FlushInput(fd);
> +
>  	return fd < 0 ? -errno : fd;
>  }
>  

can  xf86FlushInput() handle fd<0 ?
perhaps it would be better to make clear that this is an error case like:

fd = xf86OpenSerial(pInfo->options);

if (fd<0)
	return -errno ;

xf86FlushInput(fd);
return fd;

just my 2 cents,
re,
 wh







More information about the xorg-devel mailing list