]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
virCondWaitUntil: add another return value
authorPavel Hrdina <phrdina@redhat.com>
Mon, 29 Jun 2015 14:10:36 +0000 (16:10 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Thu, 9 Jul 2015 16:02:05 +0000 (18:02 +0200)
We should distinguish between success and timeout, to let the user
handle those two events differently.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
src/conf/domain_conf.c

index 0219c3c4814da3f027aa0e9f2877dc76731e16f9..bc539d5638a7a99b8a72b692b12a0c89cee68c50 100644 (file)
@@ -2687,15 +2687,25 @@ virDomainObjWait(virDomainObjPtr vm)
 }
 
 
+/**
+ * Waits for domain condition to be triggered for a specific period of time.
+ *
+ * Returns:
+ *  -1 in case of error
+ *  0 on success
+ *  1 on timeout
+ */
 int
 virDomainObjWaitUntil(virDomainObjPtr vm,
                       unsigned long long whenms)
 {
-    if (virCondWaitUntil(&vm->cond, &vm->parent.lock, whenms) < 0 &&
-        errno != ETIMEDOUT) {
-        virReportSystemError(errno, "%s",
-                             _("failed to wait for domain condition"));
-        return -1;
+    if (virCondWaitUntil(&vm->cond, &vm->parent.lock, whenms) < 0) {
+        if (errno != ETIMEDOUT) {
+            virReportSystemError(errno, "%s",
+                                 _("failed to wait for domain condition"));
+            return -1;
+        }
+        return 1;
     }
     return 0;
 }