mirror of
https://github.com/glfw/glfw.git
synced 2024-11-25 22:14:34 +00:00
X11: Retry poll when failed with EINTR or EAGAIN
Both of these errors should just lead to local retry.
This commit is contained in:
parent
d3e4fcf8b7
commit
92b5c67b50
@ -82,18 +82,26 @@ static GLFWbool waitForEvent(double* timeout)
|
|||||||
const uint64_t base = _glfwPlatformGetTimerValue();
|
const uint64_t base = _glfwPlatformGetTimerValue();
|
||||||
|
|
||||||
const int result = poll(fds, count, milliseconds);
|
const int result = poll(fds, count, milliseconds);
|
||||||
const int error = errno;
|
const int error = errno; // clock_gettime may overwrite our error
|
||||||
|
|
||||||
*timeout -= (_glfwPlatformGetTimerValue() - base) /
|
*timeout -= (_glfwPlatformGetTimerValue() - base) /
|
||||||
(double) _glfwPlatformGetTimerFrequency();
|
(double) _glfwPlatformGetTimerFrequency();
|
||||||
|
|
||||||
if (result > 0)
|
if (result > 0)
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
if ((result == -1 && error == EINTR) || *timeout <= 0.0)
|
else if (result == -1 && error != EINTR && error != EAGAIN)
|
||||||
|
return GLFW_FALSE;
|
||||||
|
else if (*timeout <= 0.0)
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const int result = poll(fds, count, -1);
|
||||||
|
if (result > 0)
|
||||||
|
return GLFW_TRUE;
|
||||||
|
else if (result == -1 && errno != EINTR && errno != EAGAIN)
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
else if (poll(fds, count, -1) != -1 || errno != EINTR)
|
|
||||||
return GLFW_TRUE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user