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

Osier Yang jyang at redhat.com
Mon Aug 1 14:55:35 UTC 2011


于 2011年08月01日 22:28, Eric Blake 写道:
> 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.
>
I think it will not only used for the shutdown cleanup, so updated
the patch to clear out sock->localAddr.data.un.sub_path.

Thanks
Osier




More information about the libvir-list mailing list