[libvirt] [PATCH 2/4] virNetSocketRemoveIOCallback: Be explicit about unref

Michal Privoznik mprivozn at redhat.com
Thu Jun 18 13:11:00 UTC 2015


When going through the code I've notice that
virNetSocketAddIOCallback() increases the reference counter of
@socket. However, its counter part RemoveIOCallback does not. It took
me a while to realize this disproportion. The AddIOCallback registers
our own callback which eventually calls the desired callback and then
unref the @sock. Yeah, a bit complicated but it works. So, lets note
this hard learned fact in a comment in RemoveIOCallback().

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/rpc/virnetsocket.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index 2497f67..81903e7 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -1993,6 +1993,7 @@ void virNetSocketRemoveIOCallback(virNetSocketPtr sock)
     }
 
     virEventRemoveHandle(sock->watch);
+    /* Don't unref @sock, it's done via evenloop callback. */
 
     virObjectUnlock(sock);
 }
-- 
2.3.6




More information about the libvir-list mailing list