network: Have virNetworkObjNew lock the returned object

Forces callers to use the virNetworkObjEndAPI properly.

Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
John Ferlan 2017-05-10 08:40:40 -04:00
parent 26c8fe4990
commit 7beef70871
2 changed files with 3 additions and 3 deletions

View File

@ -87,6 +87,8 @@ virNetworkObjNew(void)
ignore_value(virBitmapSetBit(obj->classIdMap, 1));
ignore_value(virBitmapSetBit(obj->classIdMap, 2));
virObjectLock(obj);
return obj;
error:
@ -572,8 +574,6 @@ virNetworkObjAssignDefLocked(virNetworkObjListPtr nets,
if (!(obj = virNetworkObjNew()))
goto cleanup;
virObjectLock(obj);
virUUIDFormat(def->uuid, uuidstr);
if (virHashAddEntry(nets->objs, uuidstr, obj) < 0)
goto cleanup;

View File

@ -67,7 +67,7 @@ testCompareXMLToConfFiles(const char *inxml, const char *outconf, dnsmasqCapsPtr
VIR_FREE(actual);
VIR_FREE(pidfile);
virCommandFree(cmd);
virObjectUnref(obj);
virNetworkObjEndAPI(&obj);
dnsmasqContextFree(dctx);
return ret;
}