]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
virNetServerServiceClose: Don't leak sockets
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 18 Jun 2015 12:37:43 +0000 (14:37 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 19 Jun 2015 09:19:50 +0000 (11:19 +0200)
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>
src/rpc/virnetserverservice.c

index 4df26cb52f43101de13e392619aa7a59c3496479..3b35fc092940dfdc051990d4f6de641b5f9e0e61 100644 (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);
+    }
 }