[libvirt] [PATCH] Ensure UNIX domain sockets are removed on daemon shutdown

Eric Blake eblake at redhat.com
Thu Jun 3 14:54:30 UTC 2010


On 06/03/2010 07:40 AM, Daniel P. Berrange wrote:
> When libvirtd exits it is leaving UNIX domain sockets on
> the filesystem. These need to be removed.
> 
> The qemudInitPaths() method has signficant code churn to
> switch from using a pre-allocated buffer on the stack, to
> dynamically allocating on the heap.
> 
> @@ -549,6 +549,7 @@ static int qemudListenUnix(struct qemud_server *server,
>      sock->port = -1;
>      sock->type = QEMUD_SOCK_TYPE_UNIX;
>      sock->auth = auth;
> +    sock->path = path;

This saves a reference...

> -    if (qemudInitPaths(server, sockname, roSockname, PATH_MAX) < 0)
> +    if (qemudInitPaths(server, &sockname, &roSockname) < 0)
>          goto cleanup;
>  
>      if (qemudListenUnix(server, sockname, 0, auth_unix_rw) < 0)
>          goto cleanup;
> +    sockname = NULL;
>  
> -    if (roSockname[0] != '\0' && qemudListenUnix(server, roSockname, 1, auth_unix_ro) < 0)
> +    if (roSockname != NULL && qemudListenUnix(server, roSockname, 1, auth_unix_ro) < 0)
>          goto cleanup;
> +    roSockname = NULL;

...to malloc'd storage...

> @@ -2422,6 +2424,13 @@ static void qemudCleanup(struct qemud_server *server) {
>          if (sock->watch)
>              virEventRemoveHandleImpl(sock->watch);
>          close(sock->fd);
> +
> +        /* Unlink unix domain sockets which are not in
> +         * the abstract namespace */
> +        if (sock->path &&
> +            sock->path[0] != '@')
> +            unlink(sock->path);
> +

...but this failed to free that storage.  I think you have a leak.

ACK, once you add VIR_FREE(sock->path) to qemudCleanup.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100603/e6bdd7fd/attachment-0001.sig>


More information about the libvir-list mailing list