[PATCH xserver v2] xwayland: handle EAGAIN and EINTR gracefully
Olivier Fourdan
ofourdan at redhat.com
Mon Sep 12 19:27:19 UTC 2016
wl_display_flush() can fail with EAGAIN and Xwayland would make this a
fatal error.
Handle the usual EAGAIN and EINTR gracefully so that Xwayland doesn't
die for so little.
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1278159
Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
---
v2: oops, need to poll() on EAGAIN between retries
hw/xwayland/xwayland.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index 847321e..2c7f45b 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -33,6 +33,7 @@
#include <compositeext.h>
#include <glx_extinit.h>
#include <os.h>
+#include <xserver_poll.h>
#ifdef XF86VIDMODE
#include <X11/extensions/xf86vmproto.h>
@@ -481,6 +482,23 @@ xwl_read_events (struct xwl_screen *xwl_screen)
FatalError("failed to dispatch Wayland events: %s\n", strerror(errno));
}
+static Bool
+xwl_poll_display_fd (struct xwl_screen *xwl_screen)
+{
+ struct pollfd poll_fd;
+ int ret;
+
+ poll_fd.fd = wl_display_get_fd(xwl_screen->display);
+ poll_fd.events = POLLOUT;
+ do {
+ ret = xserver_poll(&poll_fd, 1, -1);
+ if (ret > 0)
+ return TRUE;
+ } while (ret == -1 && (errno == EINTR || errno == EAGAIN));
+
+ return FALSE;
+ }
+
static void
xwl_dispatch_events (struct xwl_screen *xwl_screen)
{
@@ -496,7 +514,12 @@ xwl_dispatch_events (struct xwl_screen *xwl_screen)
xwl_screen->prepare_read = 1;
- ret = wl_display_flush(xwl_screen->display);
+ do {
+ ret = wl_display_flush(xwl_screen->display);
+ if (ret == -1 && errno == EAGAIN && xwl_poll_display_fd(xwl_screen))
+ continue;
+ } while (ret == -1 && errno == EINTR);
+
if (ret == -1)
FatalError("failed to write to XWayland fd: %s\n", strerror(errno));
}
--
2.9.3
More information about the xorg-devel
mailing list