Fix ref-counting for Xen driver event registration

This commit is contained in:
John Levon 2009-01-15 01:18:37 +00:00
parent d6511cf6de
commit 65316d7940
2 changed files with 18 additions and 5 deletions

View File

@ -1,3 +1,8 @@
Thu Jan 15 01:16:05 GMT 2009 John Levon <levon@movementarian.org>
* src/xen_unified.c: Fix ref-counting for Xen driver event
registration
Wed Jan 14 17:30:54 GMT 2009 John Levon <levon@movementarian.org>
* docs/devhelp/Makefile.am: Fix devhelp build dependencies

View File

@ -1359,15 +1359,21 @@ xenUnifiedDomainEventRegister (virConnectPtr conn,
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);
if (ret == 0)
conn->refs++;
return (ret);
}
static int
@ -1382,8 +1388,10 @@ xenUnifiedDomainEventDeregister (virConnectPtr conn,
}
ret = virDomainEventCallbackListRemove(conn, priv->domainEventCallbacks,
callback);
virUnrefConnect(conn);
callback);
if (ret == 0)
virUnrefConnect(conn);
return ret;
}