[Spice-devel] [PATCH spice-server 05/10] main-dispatcher: Use dispatcher_send_message_generic
Frediano Ziglio
fziglio at redhat.com
Wed Mar 20 09:59:14 UTC 2019
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
server/main-dispatcher.c | 38 ++++++++------------------------------
1 file changed, 8 insertions(+), 30 deletions(-)
diff --git a/server/main-dispatcher.c b/server/main-dispatcher.c
index 839e7242..904579a8 100644
--- a/server/main-dispatcher.c
+++ b/server/main-dispatcher.c
@@ -121,15 +121,6 @@ main_dispatcher_init(MainDispatcher *self)
self->priv = main_dispatcher_get_instance_private(self);
}
-enum {
- MAIN_DISPATCHER_CHANNEL_EVENT = 0,
- MAIN_DISPATCHER_MIGRATE_SEAMLESS_DST_COMPLETE,
- MAIN_DISPATCHER_SET_MM_TIME_LATENCY,
- MAIN_DISPATCHER_CLIENT_DISCONNECT,
-
- MAIN_DISPATCHER_NUM_MESSAGES
-};
-
typedef struct MainDispatcherChannelEventMessage {
int event;
SpiceChannelEventInfo *info;
@@ -168,8 +159,8 @@ void main_dispatcher_channel_event(MainDispatcher *self, int event, SpiceChannel
}
msg.event = event;
msg.info = info;
- dispatcher_send_message(DISPATCHER(self), MAIN_DISPATCHER_CHANNEL_EVENT,
- &msg);
+ dispatcher_send_message_generic(DISPATCHER(self), main_dispatcher_handle_channel_event,
+ &msg, sizeof(msg), false);
}
@@ -214,8 +205,8 @@ void main_dispatcher_seamless_migrate_dst_complete(MainDispatcher *self,
}
msg.client = g_object_ref(client);
- dispatcher_send_message(DISPATCHER(self), MAIN_DISPATCHER_MIGRATE_SEAMLESS_DST_COMPLETE,
- &msg);
+ dispatcher_send_message_generic(DISPATCHER(self), main_dispatcher_handle_migrate_complete,
+ &msg, sizeof(msg), false);
}
void main_dispatcher_set_mm_time_latency(MainDispatcher *self, RedClient *client, uint32_t latency)
@@ -229,8 +220,8 @@ void main_dispatcher_set_mm_time_latency(MainDispatcher *self, RedClient *client
msg.client = g_object_ref(client);
msg.latency = latency;
- dispatcher_send_message(DISPATCHER(self), MAIN_DISPATCHER_SET_MM_TIME_LATENCY,
- &msg);
+ dispatcher_send_message_generic(DISPATCHER(self), main_dispatcher_handle_mm_time_latency,
+ &msg, sizeof(msg), false);
}
void main_dispatcher_client_disconnect(MainDispatcher *self, RedClient *client)
@@ -240,8 +231,8 @@ void main_dispatcher_client_disconnect(MainDispatcher *self, RedClient *client)
if (!red_client_is_disconnecting(client)) {
spice_debug("client %p", client);
msg.client = g_object_ref(client);
- dispatcher_send_message(DISPATCHER(self), MAIN_DISPATCHER_CLIENT_DISCONNECT,
- &msg);
+ dispatcher_send_message_generic(DISPATCHER(self), main_dispatcher_handle_client_disconnect,
+ &msg, sizeof(msg), false);
} else {
spice_debug("client %p already during disconnection", client);
}
@@ -263,7 +254,6 @@ MainDispatcher* main_dispatcher_new(RedsState *reds)
{
MainDispatcher *self = g_object_new(TYPE_MAIN_DISPATCHER,
"spice-server", reds,
- "max-message-type", MAIN_DISPATCHER_NUM_MESSAGES,
NULL);
return self;
}
@@ -280,18 +270,6 @@ void main_dispatcher_constructed(GObject *object)
dispatcher_get_recv_fd(DISPATCHER(self)),
SPICE_WATCH_EVENT_READ, dispatcher_handle_read,
DISPATCHER(self));
- dispatcher_register_handler(DISPATCHER(self), MAIN_DISPATCHER_CHANNEL_EVENT,
- main_dispatcher_handle_channel_event,
- sizeof(MainDispatcherChannelEventMessage), false);
- dispatcher_register_handler(DISPATCHER(self), MAIN_DISPATCHER_MIGRATE_SEAMLESS_DST_COMPLETE,
- main_dispatcher_handle_migrate_complete,
- sizeof(MainDispatcherMigrateSeamlessDstCompleteMessage), false);
- dispatcher_register_handler(DISPATCHER(self), MAIN_DISPATCHER_SET_MM_TIME_LATENCY,
- main_dispatcher_handle_mm_time_latency,
- sizeof(MainDispatcherMmTimeLatencyMessage), false);
- dispatcher_register_handler(DISPATCHER(self), MAIN_DISPATCHER_CLIENT_DISCONNECT,
- main_dispatcher_handle_client_disconnect,
- sizeof(MainDispatcherClientDisconnectMessage), false);
}
static void main_dispatcher_finalize(GObject *object)
--
2.20.1
More information about the Spice-devel
mailing list