Blob Blame History Raw
From 5e35cc0386d405c415fe09cd9910f132af8d5645 Mon Sep 17 00:00:00 2001
Message-Id: <5e35cc0386d405c415fe09cd9910f132af8d5645@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Fri, 10 Jul 2015 12:39:29 +0200
Subject: [PATCH] virCondWaitUntil: add another return value

We should distinguish between success and timeout, to let the user
handle those two events differently.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
(cherry picked from commit 5c48618f114a62b463dbc8981365448826e6df8b)

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1147471

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/conf/domain_conf.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 535701e..2f1f69d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -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;
 }
-- 
2.4.5