[PATCH v2 libevdev] Drain all events before synchronizing after SYN_DROPPED
Peter Hutterer
peter.hutterer at who-t.net
Wed Apr 9 18:23:37 PDT 2014
On Thu, Apr 10, 2014 at 03:01:30AM +0200, David Herrmann wrote:
> Hi
>
> On Thu, Apr 10, 2014 at 2:57 AM, Peter Hutterer
> <peter.hutterer at who-t.net> wrote:
> > The kernel ring buffer drops all events on SYN_DROPPED, but then continues to
> > fill up again. So by the time we read the events, the kernel's client buffer is
> > essentially like this:
> > SYN_DROPPED, ev1, ev2, ev3, ...., evN
> >
> > The kernel's device state represents the device after evN, and that is what
> > the ioctls return.
>
> I fixed that about 1 year ago. If you call ioctl()s, the kernel
> _flushes_ affected events from the queue. So syncing our state via
> EVIOCG* will remove events of that type from the queue. We should
> simply do the same to our internal queue and we are fine.
>
> See: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/drivers/input/evdev.c?id=483180281f0ac60d1138710eb21f4b9961901294
>
> Sorry, currently on the road for 2 more weeks, so no time to look at
> the patch in more detail. Will do that once I get home, just wanted to
> point to the kernel-patch..
You missed the last paragraph of that commit message:
"Note that the above is true for EV_ABS events, for EV_KEY, EV_SND, EV_LED
and EV_SW the kernel removes potential duplicates from the client buffer
anyway. Really, this should be fixed in the kernel for EV_ABS, but until
then we need this solution."
What exposed this bug was a double tracking ID in the queue after sync, only
after writing the patch did I notice that the kernel already does some of
this, albeit not for EV_ABS. I'll fix up the commit message to be more
precise, but the kernel patch is still needed.
Cheers,
Peter
More information about the Input-tools
mailing list