Re: [PATCH v1 28/31] virNetworkObjFindBy*: Return an reference to found object

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 26, 2015 at 15:17:37 +0100, Michal Privoznik wrote:
> This patch turns both virNetworkObjFindByUUID() and
> virNetworkObjFindByName() to return an referenced object so that
> even if caller unlocks it, it's for sure that object won't
> disappear meanwhile. Especially if the object (in general) is
> locked and unlocked during the caller run.
> Moreover, this commit is nicely small, since the object unrefing
> can be done in virNetworkObjEndAPI().
> 
> Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
> ---
>  src/conf/network_conf.c           | 11 +++++++----
>  src/parallels/parallels_network.c |  9 +++++----
>  src/test/test_driver.c            |  4 ++--
>  3 files changed, 14 insertions(+), 10 deletions(-)
> 
> diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
> index 5b0f36f..c620201 100644
> --- a/src/conf/network_conf.c
> +++ b/src/conf/network_conf.c
> @@ -137,6 +137,7 @@ virNetworkObjEndAPI(virNetworkObjPtr *net)
>          return;
>  
>      virObjectUnlock(*net);
> +    virObjectUnref(*net);
>      *net = NULL;
>  }
>  
> @@ -164,6 +165,7 @@ virNetworkObjPtr virNetworkObjFindByUUID(virNetworkObjListPtr nets,
>          virObjectLock(nets->objs[i]);
>          if (!memcmp(nets->objs[i]->def->uuid, uuid, VIR_UUID_BUFLEN)) {
>              ret = nets->objs[i];
> +            virObjectRef(ret);
>              break;
>          }
>          virObjectUnlock(nets->objs[i]);
> @@ -184,6 +186,7 @@ virNetworkObjPtr virNetworkObjFindByName(virNetworkObjListPtr nets,
>          virObjectLock(nets->objs[i]);
>          if (STREQ(nets->objs[i]->def->name, name)) {
>              ret = nets->objs[i];
> +            virObjectRef(ret);
>              break;
>          }
>          virObjectUnlock(nets->objs[i]);

The two hunks above probably won't be a good idea in the light of the
review for 29/31.

Peter

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]