From: Michal Privoznik Date: Thu, 18 Jun 2015 12:15:08 +0000 (+0200) Subject: virNetSocketRemoveIOCallback: Be explicit about unref X-Git-Tag: v1.2.17-rc1~105 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=899e49a2e605df2b23f4ed3e905a4139379e7d75;p=thirdparty%2Flibvirt.git virNetSocketRemoveIOCallback: Be explicit about unref 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 --- diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index 2497f674ce..48107ffad1 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 eventloop callback. */ virObjectUnlock(sock); }