X11: Retry poll when failed with EINTR or EAGAIN

Both of these errors should just lead to local retry.

(cherry picked from commit 92b5c67b50)
This commit is contained in:
Camilla Löwy 2022-02-18 15:13:18 +01:00
parent ca1a98e7a2
commit b4aa5f626f
1 changed files with 12 additions and 4 deletions

View File

@ -82,18 +82,26 @@ static GLFWbool waitForEvent(double* timeout)
const uint64_t base = _glfwPlatformGetTimerValue();
const int result = poll(fds, count, milliseconds);
const int error = errno;
const int error = errno; // clock_gettime may overwrite our error
*timeout -= (_glfwPlatformGetTimerValue() - base) /
(double) _glfwPlatformGetTimerFrequency();
if (result > 0)
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;
}
else if (poll(fds, count, -1) != -1 || errno != EINTR)
return GLFW_TRUE;
}
}