diff options
author | Keith Packard <keithp@keithp.com> | 2013-12-11 10:19:57 -0800 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2014-02-24 16:05:47 -0800 |
commit | f3ecfb79a55779fc35ada808d083f16d5593fd46 (patch) | |
tree | 4d6ac37b4c27f26f95af42462f58fa3b3b29c39b | |
parent | e21afb3715b8d9334a46791e37550994c99f91ab (diff) |
The DRM fd isn't actually non-blocking; use poll to check for events
When going off to try to read the DRM fd for events, make sure there's
something present before actually reading.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
-rw-r--r-- | src/uxa/intel_display.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/uxa/intel_display.c b/src/uxa/intel_display.c index 5c75deb9..e1dc6a84 100644 --- a/src/uxa/intel_display.c +++ b/src/uxa/intel_display.c @@ -2096,13 +2096,22 @@ drm_wakeup_handler(pointer data, int err, pointer p) } /* - * Just try to read drm_events; the fd is non-blocking, so we'll get - * zero if there aren't any events to read + * If there are any available, read drm_events */ int intel_mode_read_drm_events(struct intel_screen_private *intel) { struct intel_mode *mode = intel->modes; + struct pollfd p = { .fd = mode->fd, .events = POLLIN }; + int r; + + do { + r = poll(&p, 1, 0); + } while (r == -1 && (errno == EINTR || errno == EAGAIN)); + + if (r <= 0) + return 0; + return drmHandleEvent(mode->fd, &mode->event_context); } |