libdrm: only check for vblank timeout if we caught EINTR

Michel caught a case where we might overwrite a success or other return
value with EBUSY, so check the return value before checking for the
timeout condition.
main
Jesse Barnes 2009-01-07 10:48:26 -08:00
parent f4f76a6894
commit ca37077fb7
1 changed files with 10 additions and 7 deletions

View File

@ -1910,14 +1910,17 @@ int drmWaitVBlank(int fd, drmVBlankPtr vbl)
do {
ret = ioctl(fd, DRM_IOCTL_WAIT_VBLANK, vbl);
vbl->request.type &= ~DRM_VBLANK_RELATIVE;
if (ret && errno == EINTR) {
clock_gettime(CLOCK_MONOTONIC, &cur);
/* Timeout after 1s */
if (cur.tv_sec > timeout.tv_sec + 1 ||
cur.tv_sec == timeout.tv_sec && cur.tv_nsec >= timeout.tv_nsec) {
(cur.tv_sec == timeout.tv_sec && cur.tv_nsec >=
timeout.tv_nsec)) {
errno = EBUSY;
ret = -1;
break;
}
}
} while (ret && errno == EINTR);
out: