Re: [libvirt PATCH 08/10] datatypes: Use automatic mutex management

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

 



On 3/25/22 16:02, Tim Wiederhake wrote:
> Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx>
> ---
>  src/datatypes.c | 63 +++++++++++++++----------------------------------
>  1 file changed, 19 insertions(+), 44 deletions(-)
> 
> diff --git a/src/datatypes.c b/src/datatypes.c
> index aa614612f9..da8a9970f1 100644
> --- a/src/datatypes.c
> +++ b/src/datatypes.c


>  int
> @@ -1173,14 +1153,12 @@ virAdmConnectCloseCallbackDataRegister(virAdmConnectCloseCallbackData *cbdata,
>                                         void *opaque,
>                                         virFreeCallback freecb)
>  {
> -    int ret = -1;
> -
> -    virObjectLock(cbdata);

Here, @cbdata used to be locked ...

> +    VIR_LOCK_GUARD lock = virObjectLockGuard(cbdata);
>  
>      if (cbdata->callback) {
>          virReportError(VIR_ERR_OPERATION_INVALID, "%s",
>                         _("A close callback is already registered"));
> -        goto cleanup;
> +        return -1;
>      }
>  
>      cbdata->conn = virObjectRef(conn);
> @@ -1188,10 +1166,7 @@ virAdmConnectCloseCallbackDataRegister(virAdmConnectCloseCallbackData *cbdata,
>      cbdata->opaque = opaque;
>      cbdata->freeCallback = freecb;
>  
> -    ret = 0;
> - cleanup:
> -    virObjectUnlock(conn->closeCallback);

... but ere conn->closeCallback was unlocked. I believe your change is
correct and in fact fixes this problem. But can't really verify because
this function is never called.

> -    return ret;
> +    return 0;
>  }
>  
>  virAdmServerPtr

Michal




[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]

  Powered by Linux