[libvirt] [PATCH 07/14] rpc: Correct locking and simplify the function

John Ferlan jferlan at redhat.com
Fri Dec 15 12:58:53 UTC 2017



On 12/12/2017 06:36 AM, Marc Hartmayer wrote:
> The lock for @client must not only be held for the duration of
> checking whether the client wants to close, but also for as long as
> we're closing the client.
> 
> Signed-off-by: Marc Hartmayer <mhartmay at linux.vnet.ibm.com>
> Reviewed-by: Boris Fiuczynski <fiuczy at linux.vnet.ibm.com>
> Reviewed-by: Stefan Zimmermann <stzi at linux.vnet.ibm.com>
> ---
>  src/libvirt_remote.syms      |  3 ++-
>  src/rpc/virnetserver.c       | 12 ++++++++----
>  src/rpc/virnetserverclient.c | 25 ++++++++++++++-----------
>  src/rpc/virnetserverclient.h |  3 ++-
>  4 files changed, 26 insertions(+), 17 deletions(-)
> 

Reviewed-by: John Ferlan <jferlan at redhat.com>

John

(minor nit below)

[...]

> diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c
> index 0ee299e2d6ec..96fd1e6d15c2 100644
> --- a/src/rpc/virnetserverclient.c
> +++ b/src/rpc/virnetserverclient.c

[...]

>  
> -bool virNetServerClientWantClose(virNetServerClientPtr client)
> +
> +/* @client needs to be locked by the caller */
> +bool virNetServerClientWantCloseLocked(virNetServerClientPtr client)

Seeing as you added the "newer" extra line between functions you could
also have used the "newer" multi-line function decl:

bool
virNetServerClient...



>  {
> -    bool wantClose;
> -    virObjectLock(client);
> -    wantClose = client->wantClose;
> -    virObjectUnlock(client);
> -    return wantClose;
> +    return client->wantClose;
>  }
>  
>  

[...]




More information about the libvir-list mailing list