7a3408
From 5e35cc0386d405c415fe09cd9910f132af8d5645 Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <5e35cc0386d405c415fe09cd9910f132af8d5645@dist-git>
7a3408
From: Pavel Hrdina <phrdina@redhat.com>
7a3408
Date: Fri, 10 Jul 2015 12:39:29 +0200
7a3408
Subject: [PATCH] virCondWaitUntil: add another return value
7a3408
7a3408
We should distinguish between success and timeout, to let the user
7a3408
handle those two events differently.
7a3408
7a3408
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7a3408
(cherry picked from commit 5c48618f114a62b463dbc8981365448826e6df8b)
7a3408
7a3408
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1147471
7a3408
7a3408
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7a3408
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7a3408
---
7a3408
 src/conf/domain_conf.c | 20 +++++++++++++++-----
7a3408
 1 file changed, 15 insertions(+), 5 deletions(-)
7a3408
7a3408
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
7a3408
index 535701e..2f1f69d 100644
7a3408
--- a/src/conf/domain_conf.c
7a3408
+++ b/src/conf/domain_conf.c
7a3408
@@ -2687,15 +2687,25 @@ virDomainObjWait(virDomainObjPtr vm)
7a3408
 }
7a3408
 
7a3408
 
7a3408
+/**
7a3408
+ * Waits for domain condition to be triggered for a specific period of time.
7a3408
+ *
7a3408
+ * Returns:
7a3408
+ *  -1 in case of error
7a3408
+ *  0 on success
7a3408
+ *  1 on timeout
7a3408
+ */
7a3408
 int
7a3408
 virDomainObjWaitUntil(virDomainObjPtr vm,
7a3408
                       unsigned long long whenms)
7a3408
 {
7a3408
-    if (virCondWaitUntil(&vm->cond, &vm->parent.lock, whenms) < 0 &&
7a3408
-        errno != ETIMEDOUT) {
7a3408
-        virReportSystemError(errno, "%s",
7a3408
-                             _("failed to wait for domain condition"));
7a3408
-        return -1;
7a3408
+    if (virCondWaitUntil(&vm->cond, &vm->parent.lock, whenms) < 0) {
7a3408
+        if (errno != ETIMEDOUT) {
7a3408
+            virReportSystemError(errno, "%s",
7a3408
+                                 _("failed to wait for domain condition"));
7a3408
+            return -1;
7a3408
+        }
7a3408
+        return 1;
7a3408
     }
7a3408
     return 0;
7a3408
 }
7a3408
-- 
7a3408
2.4.5
7a3408