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