summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Cardell Widerkrantz <mc@hack.org>2012-02-07 21:01:51 +0100
committerMichael Cardell Widerkrantz <mc@hack.org>2012-02-07 21:01:51 +0100
commit8a99196db3ccff3f6b13deb58cda9dbf84ad9009 (patch)
tree10412342ec6191b1d4497687f819810fbab1b6e2
parentec483ba317c6d2fb5465dcecc37e3d6492d061c1 (diff)
downloadmcwm-8a99196db3ccff3f6b13deb58cda9dbf84ad9009.zip
Always check for unrecoverable errors when xcb_poll_for_event()
returns NULL. Our file descriptor *might* have become unreadable.
-rw-r--r--mcwm.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/mcwm.c b/mcwm.c
index 7e3c462..3f187aa 100644
--- a/mcwm.c
+++ b/mcwm.c
@@ -3359,9 +3359,9 @@ void events(void)
FD_SET(fd, &in);
/*
- * Check for events, again and again. When poll returns NULL,
- * we block on select() until the event file descriptor gets
- * readable again.
+ * Check for events, again and again. When poll returns NULL
+ * (and it does that a lot), we block on select() until the
+ * event file descriptor gets readable again.
*
* We do it this way instead of xcb_wait_for_event() since
* select() will return if we were interrupted by a signal. We
@@ -3370,6 +3370,18 @@ void events(void)
ev = xcb_poll_for_event(conn);
if (NULL == ev)
{
+ PDEBUG("xcb_poll_for_event() returned NULL.\n");
+
+ /*
+ * Check if we have an unrecoverable connection error,
+ * like a disconnected X server.
+ */
+ if (xcb_connection_has_error(conn))
+ {
+ cleanup(0);
+ exit(1);
+ }
+
found = select(fd + 1, &in, NULL, NULL, NULL);
if (-1 == found)
{