Re: [PATCH v5 07/13] Add support for async close of client RPC socket

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

 



On Tue, Nov 22, 2011 at 04:45:27PM +0100, Jiri Denemark wrote:
> ---
> Notes:
>     Version 5:
>     - rebased on top of DanB's non-blocking patches; this is the only part that
>       required non-trivial rebase so I'm posting it for additional review
>     
>     Version 4:
>     - no changes
>     
>     Version 3:
>     - no changes
>     
>     Version 2:
>     - no changes
> 
>  src/rpc/virnetclient.c |   99 +++++++++++++++++++++++++++++++++++++++++++----
>  1 files changed, 90 insertions(+), 9 deletions(-)
> 
> diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
> index 025d270..b4b2fe7 100644
> --- a/src/rpc/virnetclient.c
> +++ b/src/rpc/virnetclient.c
> @@ -101,9 +101,13 @@ struct _virNetClient {
>  
>      size_t nstreams;
>      virNetClientStreamPtr *streams;
> +
> +    bool wantClose;
>  };
>  
>  
> +void virNetClientRequestClose(virNetClientPtr client);
> +
>  static void virNetClientLock(virNetClientPtr client)
>  {
>      virMutexLock(&client->lock);
> @@ -409,12 +413,14 @@ void virNetClientFree(virNetClientPtr client)
>  }
>  
>  
> -void virNetClientClose(virNetClientPtr client)
> +static void
> +virNetClientCloseLocked(virNetClientPtr client)
>  {
> -    if (!client)
> +    VIR_DEBUG("client=%p, sock=%p", client, client->sock);
> +
> +    if (!client->sock)
>          return;
>  
> -    virNetClientLock(client);
>      virNetSocketRemoveIOCallback(client->sock);
>      virNetSocketFree(client->sock);
>      client->sock = NULL;
> @@ -424,6 +430,41 @@ void virNetClientClose(virNetClientPtr client)
>      virNetSASLSessionFree(client->sasl);
>      client->sasl = NULL;
>  #endif
> +    client->wantClose = false;
> +}
> +
> +void virNetClientClose(virNetClientPtr client)
> +{
> +    if (!client)
> +        return;
> +
> +    virNetClientLock(client);
> +    virNetClientCloseLocked(client);
> +    virNetClientUnlock(client);
> +}
> +
> +void
> +virNetClientRequestClose(virNetClientPtr client)
> +{
> +    VIR_DEBUG("client=%p", client);
> +
> +    virNetClientLock(client);
> +
> +    /* If there is a thread polling for data on the socket, set wantClose flag
> +     * and wake the thread up or just immediately close the socket when no-one
> +     * is polling on it.
> +     */
> +    if (client->waitDispatch) {
> +        char ignore = 1;
> +        int len = sizeof(ignore);

Minor nitpick   s/int/size_t/

ACK

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

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