提交 ae0dcbc4 编写于 作者: O Osier Yang

daemon: Unlink unix socket paths on shutdown

This patch introduces a internal RPC API "virNetServerClose", which
is standalone with "virNetServerFree".  it closes all the socket fds,
and unlinks the unix socket paths, regardless of whether the socket
is still referenced or not.

This is to address regression bug:
https://bugzilla.redhat.com/show_bug.cgi?id=725702
上级 02eab9ce
......@@ -1558,6 +1558,7 @@ int main(int argc, char **argv) {
cleanup:
virNetServerProgramFree(remoteProgram);
virNetServerProgramFree(qemuProgram);
virNetServerClose(srv);
virNetServerFree(srv);
if (statuswrite != -1) {
if (ret != 0) {
......
......@@ -798,3 +798,19 @@ void virNetServerFree(virNetServerPtr srv)
virMutexDestroy(&srv->lock);
VIR_FREE(srv);
}
void virNetServerClose(virNetServerPtr srv)
{
int i;
if (!srv)
return;
virNetServerLock(srv);
for (i = 0; i < srv->nservices; i++) {
virNetServerServiceClose(srv->services[i]);
}
virNetServerUnlock(srv);
}
......@@ -85,5 +85,6 @@ void virNetServerQuit(virNetServerPtr srv);
void virNetServerFree(virNetServerPtr srv);
void virNetServerClose(virNetServerPtr srv);
#endif
......@@ -280,3 +280,15 @@ void virNetServerServiceToggle(virNetServerServicePtr svc,
VIR_EVENT_HANDLE_READABLE :
0);
}
void virNetServerServiceClose(virNetServerServicePtr svc)
{
int i;
if (!svc)
return;
for (i = 0; i < svc->nsocks; i++) {
virNetSocketClose(svc->socks[i]);
}
}
......@@ -66,4 +66,6 @@ void virNetServerServiceFree(virNetServerServicePtr svc);
void virNetServerServiceToggle(virNetServerServicePtr svc,
bool enabled);
void virNetServerServiceClose(virNetServerServicePtr svc);
#endif
......@@ -1222,3 +1222,25 @@ void virNetSocketRemoveIOCallback(virNetSocketPtr sock)
virMutexUnlock(&sock->lock);
}
void virNetSocketClose(virNetSocketPtr sock)
{
if (!sock)
return;
virMutexLock(&sock->lock);
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') {
if (unlink(sock->localAddr.data.un.sun_path) == 0)
sock->localAddr.data.un.sun_path[0] = '\0';
}
#endif
virMutexUnlock(&sock->lock);
}
......@@ -118,6 +118,7 @@ void virNetSocketUpdateIOCallback(virNetSocketPtr sock,
void virNetSocketRemoveIOCallback(virNetSocketPtr sock);
void virNetSocketClose(virNetSocketPtr sock);
#endif /* __VIR_NET_SOCKET_H__ */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
新手
引导
客服 返回
顶部