OSDN Git Service

libdrm: only check for vblank timeout if we caught EINTR
authorJesse Barnes <jbarnes@virtuousgeek.org>
Wed, 7 Jan 2009 18:48:26 +0000 (10:48 -0800)
committerJesse Barnes <jbarnes@virtuousgeek.org>
Wed, 7 Jan 2009 18:48:26 +0000 (10:48 -0800)
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.

libdrm/xf86drm.c

index 3396e28..55df19a 100644 (file)
@@ -1910,13 +1910,16 @@ int drmWaitVBlank(int fd, drmVBlankPtr vbl)
     do {
        ret = ioctl(fd, DRM_IOCTL_WAIT_VBLANK, vbl);
        vbl->request.type &= ~DRM_VBLANK_RELATIVE;
-       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) {
-          errno = EBUSY;
-          ret = -1;
-          break;
+       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)) {
+                      errno = EBUSY;
+                      ret = -1;
+                      break;
+              }
        }
     } while (ret && errno == EINTR);