提交 921af429 编写于 作者: J Jiri Denemark

rpc: Avoid deadlock when closing client connection

We need to drop the server lock before calling virObjectUnlock(client)
since in case we had the last reference to the client, its dispose
callback would be called and that could possibly try to lock the server
and cause a deadlock. This is exactly what happens when there is only
one QEMU domain running and it is marked to be autodestroyed when the
connection dies. This results in qemuProcessAutoDestroy ->
qemuProcessStop -> virNetServerRemoveShutdownInhibition call sequence,
where the last function locks the server.
上级 ee1d6d91
...@@ -1120,7 +1120,7 @@ void virNetServerRun(virNetServerPtr srv) ...@@ -1120,7 +1120,7 @@ void virNetServerRun(virNetServerPtr srv)
if (virNetServerClientWantClose(srv->clients[i])) if (virNetServerClientWantClose(srv->clients[i]))
virNetServerClientClose(srv->clients[i]); virNetServerClientClose(srv->clients[i]);
if (virNetServerClientIsClosed(srv->clients[i])) { if (virNetServerClientIsClosed(srv->clients[i])) {
virObjectUnref(srv->clients[i]); virNetServerClientPtr client = srv->clients[i];
if (srv->nclients > 1) { if (srv->nclients > 1) {
memmove(srv->clients + i, memmove(srv->clients + i,
srv->clients + i + 1, srv->clients + i + 1,
...@@ -1131,6 +1131,10 @@ void virNetServerRun(virNetServerPtr srv) ...@@ -1131,6 +1131,10 @@ void virNetServerRun(virNetServerPtr srv)
srv->nclients = 0; srv->nclients = 0;
} }
virObjectUnlock(srv);
virObjectUnref(client);
virObjectLock(srv);
goto reprocess; goto reprocess;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册