summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Gerecke <killertofu@gmail.com>2017-05-26 14:27:19 -0700
committerPeter Hutterer <peter.hutterer@who-t.net>2017-05-29 13:53:39 +1000
commit2fbf62b2fb3dcb29551251d09aa695715bb754f4 (patch)
tree2cdf8af4ff66e3e70a3be59ef4fe6f51444645fb
parent96af794dc648eadcd596893412d7530e92cb5421 (diff)
xfree86: Fix interpretation of xf86WaitForInput timeout
Commit aa6717ce2 switched xf86WaitForInput from using select(2) to using poll(2). Before this change, the timeout was interpreted as being in microseconds; afterwards it is fed directly to xorg_poll which interprets it as being in milliseconds. This results in the function potentially blocking 1000x longer than intended. This commit scales down the timeout argument before passing it to xorg_poll, being careful to ensure the result is not rounded down due to integer division. Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--hw/xfree86/os-support/shared/posix_tty.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/hw/xfree86/os-support/shared/posix_tty.c b/hw/xfree86/os-support/shared/posix_tty.c
index 6249a625c..a795ae19d 100644
--- a/hw/xfree86/os-support/shared/posix_tty.c
+++ b/hw/xfree86/os-support/shared/posix_tty.c
@@ -394,6 +394,9 @@ xf86WaitForInput(int fd, int timeout)
poll_fd.fd = fd;
poll_fd.events = POLLIN;
+ /* convert microseconds to milliseconds */
+ timeout = (timeout + 999) / 1000;
+
if (fd >= 0) {
SYSCALL(r = xserver_poll(&poll_fd, 1, timeout));
}