aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Barnes2009-01-07 12:48:26 -0600
committerJesse Barnes2009-01-07 12:48:26 -0600
commitca37077fb78b69a00500827f1db12b70affa1514 (patch)
tree617e969a660389f1f7a4b502a9c948e88d28b215 /libdrm/xf86drm.c
parentf4f76a6894b40abd77f0ffbf52972127608b9bca (diff)
downloadlibdrm-ca37077fb78b69a00500827f1db12b70affa1514.tar.gz
libdrm-ca37077fb78b69a00500827f1db12b70affa1514.tar.xz
libdrm-ca37077fb78b69a00500827f1db12b70affa1514.zip
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.
Diffstat (limited to 'libdrm/xf86drm.c')
-rw-r--r--libdrm/xf86drm.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/libdrm/xf86drm.c b/libdrm/xf86drm.c
index 3396e283..55df19ab 100644
--- a/libdrm/xf86drm.c
+++ b/libdrm/xf86drm.c
@@ -1910,13 +1910,16 @@ int drmWaitVBlank(int fd, drmVBlankPtr vbl)
1910 do { 1910 do {
1911 ret = ioctl(fd, DRM_IOCTL_WAIT_VBLANK, vbl); 1911 ret = ioctl(fd, DRM_IOCTL_WAIT_VBLANK, vbl);
1912 vbl->request.type &= ~DRM_VBLANK_RELATIVE; 1912 vbl->request.type &= ~DRM_VBLANK_RELATIVE;
1913 clock_gettime(CLOCK_MONOTONIC, &cur); 1913 if (ret && errno == EINTR) {
1914 /* Timeout after 1s */ 1914 clock_gettime(CLOCK_MONOTONIC, &cur);
1915 if (cur.tv_sec > timeout.tv_sec + 1 || 1915 /* Timeout after 1s */
1916 cur.tv_sec == timeout.tv_sec && cur.tv_nsec >= timeout.tv_nsec) { 1916 if (cur.tv_sec > timeout.tv_sec + 1 ||
1917 errno = EBUSY; 1917 (cur.tv_sec == timeout.tv_sec && cur.tv_nsec >=
1918 ret = -1; 1918 timeout.tv_nsec)) {
1919 break; 1919 errno = EBUSY;
1920 ret = -1;
1921 break;
1922 }
1920 } 1923 }
1921 } while (ret && errno == EINTR); 1924 } while (ret && errno == EINTR);
1922 1925