john.levon(a)sun.com wrote:
Fix ref-counting for Xen driver event registration
diff --git a/src/xen_unified.c b/src/xen_unified.c
--- a/src/xen_unified.c
+++ b/src/xen_unified.c
@@ -1359,15 +1359,21 @@ xenUnifiedDomainEventRegister (virConnec
void *opaque,
void (*freefunc)(void *))
{
+ int ret;
+
GET_PRIVATE (conn);
if (priv->xsWatch == -1) {
xenUnifiedError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
return -1;
}
- conn->refs++;
- return virDomainEventCallbackListAdd(conn, priv->domainEventCallbacks,
- callback, opaque, freefunc);
+ ret = virDomainEventCallbackListAdd(conn, priv->domainEventCallbacks,
+ callback, opaque, freefunc);
This looks like a fine change, too, but please adjust it not
to change the indentation of the above continuation line:
ret = virDomainEventCallbackListAdd(conn, priv->domainEventCallbacks,
callback, opaque, freefunc);
+
+ if (ret == 0)
+ conn->refs++;
+
+ return (ret);
}
static int
@@ -1382,8 +1388,10 @@ xenUnifiedDomainEventDeregister (virConn
}
ret = virDomainEventCallbackListRemove(conn, priv->domainEventCallbacks,
- callback);
- virUnrefConnect(conn);
+ callback);
Same here.