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>
This commit is contained in:
Pavel Hrdina 2015-06-29 16:10:36 +02:00
parent b5c2245b0c
commit 5c48618f11

View 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 int
virDomainObjWaitUntil(virDomainObjPtr vm, virDomainObjWaitUntil(virDomainObjPtr vm,
unsigned long long whenms) unsigned long long whenms)
{ {
if (virCondWaitUntil(&vm->cond, &vm->parent.lock, whenms) < 0 && if (virCondWaitUntil(&vm->cond, &vm->parent.lock, whenms) < 0) {
errno != ETIMEDOUT) { if (errno != ETIMEDOUT) {
virReportSystemError(errno, "%s", virReportSystemError(errno, "%s",
_("failed to wait for domain condition")); _("failed to wait for domain condition"));
return -1; return -1;
}
return 1;
} }
return 0; return 0;
} }