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

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

 



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@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP 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]