On 10/16/2015 02:12 PM, Erik Skultety wrote:
As we need a client disconnect handler, we also need a mechanism to
register
such handlers for a client. This patch introduced both the close callbacks and
also the client vshAdmCatchDisconnect handler to be registered with it. By
registering the handler we still need to make sure the client can react to
daemon's events like disconnect or keepalive, so asynchronous I/O event polling
is necessary to be enabled too.
---
include/libvirt/libvirt-admin.h | 19 +++++++
src/admin/admin_remote.c | 36 +++++++++++++
src/datatypes.c | 20 +++++++
src/datatypes.h | 14 ++++-
src/libvirt-admin.c | 112 ++++++++++++++++++++++++++++++++++++++++
src/libvirt_admin_public.syms | 2 +
tools/virt-admin.c | 50 ++++++++++++++++++
7 files changed, 252 insertions(+), 1 deletion(-)
Ran the series through the Coverity checks...
[...]
diff --git a/src/datatypes.c b/src/datatypes.c
index aeac301..603b168 100644
--- a/src/datatypes.c
+++ b/src/datatypes.c
@@ -60,8 +60,10 @@ static void virStorageVolDispose(void *obj);
static void virStoragePoolDispose(void *obj);
virClassPtr virAdmConnectClass;
+virClassPtr virAdmConnectCloseCallbackDataClass;
static void virAdmConnectDispose(void *obj);
+static void virAdmConnectCloseCallbackDataDispose(void *obj);
static int
virDataTypesOnceInit(void)
@@ -91,6 +93,7 @@ virDataTypesOnceInit(void)
DECLARE_CLASS(virStoragePool);
DECLARE_CLASS_LOCKABLE(virAdmConnect);
+ DECLARE_CLASS_LOCKABLE(virAdmConnectCloseCallbackData);
#undef DECLARE_CLASS_COMMON
#undef DECLARE_CLASS_LOCKABLE
@@ -822,6 +825,9 @@ virAdmConnectNew(void)
if (!(ret = virObjectLockableNew(virAdmConnectClass)))
return NULL;
+ if (!(ret->closeCallback =
virObjectLockableNew(virAdmConnectCloseCallbackDataClass)))
+ return NULL;
+
You'll need to free ret or have some sort of cleanup here.
John
return ret;
}
@@ -834,4 +840,18 @@ virAdmConnectDispose(void *obj)
conn->privateDataFreeFunc(conn);
virURIFree(conn->uri);
+ virObjectUnref(conn->closeCallback);
+}
+
+static void
+virAdmConnectCloseCallbackDataDispose(void *obj)
+{
+ virAdmConnectCloseCallbackDataPtr cb_data = obj;
+
+ virObjectLock(cb_data);
+
+ if (cb_data->freeCallback)
+ cb_data->freeCallback(cb_data->opaque);
+
+ virObjectUnlock(cb_data);
}
[...]