diff options
author | Michael Cardell Widerkrantz <mc@hack.org> | 2012-02-07 21:01:51 +0100 |
---|---|---|
committer | Michael Cardell Widerkrantz <mc@hack.org> | 2012-02-07 21:01:51 +0100 |
commit | 8a99196db3ccff3f6b13deb58cda9dbf84ad9009 (patch) | |
tree | 10412342ec6191b1d4497687f819810fbab1b6e2 | |
parent | ec483ba317c6d2fb5465dcecc37e3d6492d061c1 (diff) | |
download | mcwm-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.c | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -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) { |