]> xenbits.xensource.com Git - libvirt.git/commitdiff
network: Move virObjectRef during AssignDef processing
authorJohn Ferlan <jferlan@redhat.com>
Wed, 26 Jul 2017 13:43:12 +0000 (09:43 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 16 Aug 2017 18:17:57 +0000 (14:17 -0400)
Move the virObjectRef in virNetworkObjAssignDefLocked to after
the virHashAddEntry to make it "clearer" why the @ref is being
incremented. Upon return from the ObjNew we will have 1 ref on
the object already, adding it to the hash table requires the
increment.

Signed-off-by: John Ferlan <jferlan@redhat.com>
src/conf/virnetworkobj.c

index 41a6c338093d540563019f8af11595a3683afe5f..d1636bcc1bc8bd66219fea8d1bd08bf118603a54 100644 (file)
@@ -577,10 +577,10 @@ virNetworkObjAssignDefLocked(virNetworkObjListPtr nets,
         virUUIDFormat(def->uuid, uuidstr);
         if (virHashAddEntry(nets->objs, uuidstr, obj) < 0)
             goto cleanup;
+        virObjectRef(obj);
 
         obj->def = def;
         obj->persistent = !(flags & VIR_NETWORK_OBJ_LIST_ADD_LIVE);
-        virObjectRef(obj);
     }
 
     ret = obj;