Re: [PATCH] daemon: Unlink unix socket paths on shutdown

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

 



On 08/01/2011 08:38 AM, Osier Yang wrote:
> +++ b/src/rpc/virnetsocket.c
> @@ -1222,3 +1222,19 @@ void virNetSocketRemoveIOCallback(virNetSocketPtr sock)
>  
>      virMutexUnlock(&sock->lock);
>  }
> +
> +void virNetSocketClose(virNetSocketPtr sock)
> +{

Can this be called on more than one cleanup path?  If so,

> +    if (!sock)
> +        return;
> +
> +    VIR_FORCE_CLOSE(sock->fd);
> +
> +#ifdef HAVE_SYS_UN_H
> +    /* If a server socket, then unlink UNIX path */
> +    if (!sock->client &&
> +        sock->localAddr.data.sa.sa_family == AF_UNIX &&
> +        sock->localAddr.data.un.sun_path[0] != '\0')
> +        unlink(sock->localAddr.data.un.sun_path);

you should clear out sock->localAddr.data.un.sun_path after unlinking
the file, so that the next caller doesn't try to unlink a missing file.

Also, this probably needs locking.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

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