Fix EINTR not being handled for select on X11

Closes #580.
This commit is contained in:
Camilla Berglund 2015-08-14 13:49:52 +02:00
parent ce2ec035f4
commit cc752ad6a0
2 changed files with 15 additions and 4 deletions

View File

@ -89,6 +89,7 @@ GLFW bundles a number of dependencies in the `deps/` directory.
full screen windows
- [X11] Bugfix: `GLFW_ARROW_CURSOR` selected the wrong cursor image
- [X11] Bugfix: The `GLFW_DECORATED` hint was not ignored for full screen
- [X11] Bugfix: `glfwWaitEvents` did not handle `EINTR` for `select`
- [WGL] Made all WGL functions dynamically loaded
- [WGL] Removed `GLFW_USE_DWM_SWAP_INTERVAL` compile-time option
- [WGL] Bugfix: Swap interval was ignored when DWM was enabled
@ -163,6 +164,7 @@ skills.
- Robin Leffmann
- Glenn Lewis
- Shane Liesegang
- Eyal Lotem
- Дмитри Малышев
- Martins Mozeiko
- Tristam MacDonald

View File

@ -36,6 +36,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <errno.h>
// Action for EWMH client messages
#define _NET_WM_STATE_REMOVE 0
@ -63,15 +64,23 @@ typedef struct
void selectDisplayConnection(struct timeval* timeout)
{
fd_set fds;
int result;
const int fd = ConnectionNumber(_glfw.x11.display);
FD_ZERO(&fds);
FD_SET(fd, &fds);
// select(1) is used instead of an X function like XNextEvent, as the
// wait inside those are guarded by the mutex protecting the display
// struct, locking out other threads from using X (including GLX)
select(fd + 1, &fds, NULL, NULL, timeout);
// NOTE: We use select instead of an X function like XNextEvent, as the
// wait inside those are guarded by the mutex protecting the display
// struct, locking out other threads from using X (including GLX)
// NOTE: Only retry on EINTR if there is no timeout, as select is not
// required to update it for the time elapsed
// TODO: Update timeout value manually
do
{
result = select(fd + 1, &fds, NULL, NULL, timeout);
}
while (result == -1 && errno == EINTR && timeout == NULL);
}
// Returns whether the window is iconified