Make EvdevRead() return errors to the caller

Errors during read() in EvdevRead() are not passed back to the caller.
This is problematic for level-triggered IO polling, because permanent
errors (such as device removal) are not detected and we will continue to
poll the device forever without handling the error.

This manifests itself as the device polling thread spinning, and non-IO
tasks (device hotplug, feedback collection) do not make progress because
MessagePumpLibevent never yields until there's no work to do.

xf86-input-cmt expects errno values to be returned from EvdevRead() (even
though it wasn't doing so), so return the errno value upon failure.
Temporary errors still return success; otherwise we also need to patch
the call site.

BUG=chromium:475132,chrome-os-partner:38908,chrome-os-partner:38562
TEST=Change chrome to delay unplug events to make the bug reproduce
     easily, then remove a mouse from the system. Without fix, device
     thread spins at 100% CPU and hotplug stops making progress. With
     fix, the error is detected and the libevent watcher gets cancelled.

Change-Id: I5c968c89f8bed72ba48124313136605754599c88
Reviewed-on: https://chromium-review.googlesource.com/264980
Reviewed-by: Kevin Schoedel <kpschoedel@chromium.org>
Reviewed-by: Alex Sakhartchouk <alexst@chromium.org>
Tested-by: Michael Spang <spang@chromium.org>
Commit-Queue: Matthew Yuan <matthewyuan@chromium.org>
1 file changed
tree: a4d83d973dc3111823c728e119bd9ab705f90c1d
  1. include/
  2. src/
  3. common.mk
  4. libevdev-cros.pc
  5. Makefile