[Spice-devel] [PATCH v2 1/4] server/dispatcher: add extra_dispatcher, hack for red_record
Frediano Ziglio
fziglio at redhat.com
Mon Aug 17 08:34:14 PDT 2015
From: Alon Levy <alon at pobox.com>
Signed-off-by: Alon Levy <alon at pobox.com>
---
server/dispatcher.c | 10 ++++++++++
server/dispatcher.h | 12 ++++++++++++
2 files changed, 22 insertions(+)
diff --git a/server/dispatcher.c b/server/dispatcher.c
index 298f5f9..655d13f 100644
--- a/server/dispatcher.c
+++ b/server/dispatcher.c
@@ -135,6 +135,9 @@ static int dispatcher_handle_single_read(Dispatcher *dispatcher)
/* TODO: close socketpair? */
return 0;
}
+ if (dispatcher->extra_handler) {
+ dispatcher->extra_handler(dispatcher->opaque, type, (void *)payload);
+ }
if (msg->handler) {
msg->handler(dispatcher->opaque, (void *)payload);
} else {
@@ -223,6 +226,13 @@ void dispatcher_register_handler(Dispatcher *dispatcher, uint32_t message_type,
}
}
+void dispatcher_register_extra_handler(
+ Dispatcher *dispatcher,
+ dispatcher_handle_extra_message extra_handler)
+{
+ dispatcher->extra_handler = extra_handler;
+}
+
#ifdef DEBUG_DISPATCHER
static void dummy_handler(int bla)
{
diff --git a/server/dispatcher.h b/server/dispatcher.h
index 1b389bd..9b69182 100644
--- a/server/dispatcher.h
+++ b/server/dispatcher.h
@@ -8,6 +8,10 @@ typedef struct Dispatcher Dispatcher;
typedef void (*dispatcher_handle_message)(void *opaque,
void *payload);
+typedef void (*dispatcher_handle_extra_message)(void *opaque,
+ uint32_t message_type,
+ void *payload);
+
typedef void (*dispatcher_handle_async_done)(void *opaque,
uint32_t message_type,
void *payload);
@@ -32,6 +36,7 @@ struct Dispatcher {
size_t payload_size; /* used to track realloc calls */
void *opaque;
dispatcher_handle_async_done handle_async_done;
+ dispatcher_handle_extra_message extra_handler;
};
/*
@@ -85,6 +90,13 @@ void dispatcher_register_async_done_callback(
dispatcher_handle_async_done handler);
/*
+ * Hack to allow red_record to see the message being sent so it can record
+ * it to file.
+ */
+void dispatcher_register_extra_handler(Dispatcher *dispatcher,
+ dispatcher_handle_extra_message handler);
+
+/*
* dispatcher_handle_recv_read
* @dispatcher: Dispatcher instance
*/
--
2.4.3
More information about the Spice-devel
mailing list