提交 10c2bb2b 编写于 作者: J John Ferlan

util: Introduce virObjectGetLockableObj

Split out the object fetch in virObject{Lock|Unlock} into a helper
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 209a95e3
......@@ -309,6 +309,22 @@ virObjectRef(void *anyobj)
}
static virObjectLockablePtr
virObjectGetLockableObj(void *anyobj)
{
virObjectPtr obj;
if (virObjectIsClass(anyobj, virObjectLockableClass))
return anyobj;
obj = anyobj;
VIR_WARN("Object %p (%s) is not a virObjectLockable instance",
anyobj, obj ? obj->klass->name : "(unknown)");
return NULL;
}
/**
* virObjectLock:
* @anyobj: any instance of virObjectLockablePtr
......@@ -324,13 +340,10 @@ virObjectRef(void *anyobj)
void
virObjectLock(void *anyobj)
{
virObjectLockablePtr obj = anyobj;
virObjectLockablePtr obj = virObjectGetLockableObj(anyobj);
if (!virObjectIsClass(obj, virObjectLockableClass)) {
VIR_WARN("Object %p (%s) is not a virObjectLockable instance",
obj, obj ? obj->parent.klass->name : "(unknown)");
if (!obj)
return;
}
virMutexLock(&obj->lock);
}
......@@ -346,13 +359,10 @@ virObjectLock(void *anyobj)
void
virObjectUnlock(void *anyobj)
{
virObjectLockablePtr obj = anyobj;
virObjectLockablePtr obj = virObjectGetLockableObj(anyobj);
if (!virObjectIsClass(obj, virObjectLockableClass)) {
VIR_WARN("Object %p (%s) is not a virObjectLockable instance",
obj, obj ? obj->parent.klass->name : "(unknown)");
if (!obj)
return;
}
virMutexUnlock(&obj->lock);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册