Misc fixes to event registration failure cases

This commit is contained in:
Daniel P. Berrange 2008-11-21 10:22:58 +00:00
parent 41f14d6ea5
commit 660418cff4
2 changed files with 18 additions and 4 deletions

View File

@ -1,3 +1,10 @@
Fri Nov 21 10:20:14 BST 2008 Daniel P. Berrange <berrange@redhat.com>
* src/remote_internal.c: Return VIR_NO_SUPPORT if requested
to register event callbacks when no eventloop is present.
Deal with failure to register handles/timers correctly.
(David Lively)
Fri Nov 21 10:14:14 BST 2008 Daniel P. Berrange <berrange@redhat.com>
Fix crash due to failure to unregister event callbacks on

View File

@ -773,6 +773,7 @@ doRemoteOpen (virConnectPtr conn,
conn, NULL)) < 0) {
DEBUG0("virEventAddTimeout failed: No addTimeoutImpl defined. "
"continuing without events.");
virEventRemoveHandle(priv->watch);
}
}
/* Successful. */
@ -1211,10 +1212,12 @@ doRemoteClose (virConnectPtr conn, struct private_data *priv)
(xdrproc_t) xdr_void, (char *) NULL) == -1)
return -1;
/* Remove handle for remote events */
virEventRemoveHandle(priv->sock);
/* Remove timout */
virEventRemoveTimeout(priv->eventFlushTimer);
if (priv->eventFlushTimer >= 0) {
/* Remove timeout */
virEventRemoveTimeout(priv->eventFlushTimer);
/* Remove handle for remote events */
virEventRemoveHandle(priv->watch);
}
/* Close socket. */
if (priv->uses_tls && priv->session) {
@ -4483,6 +4486,10 @@ static int remoteDomainEventRegister (virConnectPtr conn,
{
struct private_data *priv = conn->privateData;
if (priv->eventFlushTimer < 0) {
error (conn, VIR_ERR_NO_SUPPORT, _("no event support"));
return -1;
}
if (virDomainEventCallbackListAdd(conn, priv->callbackList,
callback, opaque, freecb) < 0) {
error (conn, VIR_ERR_RPC, _("adding cb to list"));