virNetServerServiceClose: Don't leak sockets

Well, if a server is being destructed, all underlying services and
their sockets should disappear with it. But due to bug in our
implementation this is not the case. Yes, we are closing the sockets,
but that's not enough. We must also:

1) Unregister them from the event loop
2) Unref the service for each socket

The last step is needed, because each socket callback holds a
reference to the service object. Since in the first step we are
unregistering the callbacks, they no longer need the reference.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Michal Privoznik 2015-06-18 14:37:43 +02:00
parent 9ee5a79830
commit 355d8f470f

View File

@ -520,6 +520,9 @@ void virNetServerServiceClose(virNetServerServicePtr svc)
if (!svc)
return;
for (i = 0; i < svc->nsocks; i++)
for (i = 0; i < svc->nsocks; i++) {
virNetSocketRemoveIOCallback(svc->socks[i]);
virNetSocketClose(svc->socks[i]);
virObjectUnref(svc);
}
}