
On 06/18/2015 03:11 PM, Michal Privoznik wrote:
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@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. */
s/evenloop/eventloop Since this is a note/reminder you could mark this one as NOTE.
virObjectUnlock(sock); }
ACK with that minor adjustment. Erik