Rather than unlock the object that was expected to be locked on
input, let the caller perform the unlock or more succinctly a
virInterfaceObjEndAPI on the object which will perform the Unref
and Unlock and clear the @obj.
Also add comments to the virInterfaceObjListRemove.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/conf/virinterfaceobj.c | 13 ++++++++++++-
src/test/test_driver.c | 2 +-
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c
index f90c0bd9c4..28fbbaa08b 100644
--- a/src/conf/virinterfaceobj.c
+++ b/src/conf/virinterfaceobj.c
@@ -358,6 +358,18 @@ virInterfaceObjListAssignDef(virInterfaceObjListPtr interfaces,
}
+/*
+ * virInterfaceObjListRemove:
+ * @interfaces: list of interface objects
+ * @obj: an interface object
+ *
+ * Remove @obj from the interface obj list hash table. The caller must hold
+ * the lock on @obj to ensure no one else is either waiting for @obj or
+ * still using it.
+ *
+ * Upon return the @obj remains locked with at least 1 reference and
+ * the caller is expected to use virInterfaceObjEndAPI on it.
+ */
void
virInterfaceObjListRemove(virInterfaceObjListPtr interfaces,
virInterfaceObjPtr obj)
@@ -370,7 +382,6 @@ virInterfaceObjListRemove(virInterfaceObjListPtr interfaces,
virObjectRWLockWrite(interfaces);
virObjectLock(obj);
virHashRemoveEntry(interfaces->objsName, obj->def->name);
- virObjectUnlock(obj);
virObjectUnref(obj);
virObjectRWUnlock(interfaces);
}
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 4de0cc5333..b0aa350d95 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -4085,7 +4085,7 @@ testInterfaceUndefine(virInterfacePtr iface)
return -1;
virInterfaceObjListRemove(privconn->ifaces, obj);
- virObjectUnref(obj);
+ virInterfaceObjEndAPI(&obj);
return 0;
}
--
2.13.6