[PATCH 1/7] server/dispatcher: pass message_type to callbacks for consistency

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Alon Levy <alon@xxxxxxxxx>

---
 server/dispatcher.c      |  2 +-
 server/dispatcher.h      |  1 +
 server/main_dispatcher.c |  4 +++
 server/red_worker.c      | 74 +++++++++++++++++++++++++-----------------------
 4 files changed, 44 insertions(+), 37 deletions(-)

diff --git a/server/dispatcher.c b/server/dispatcher.c
index 298f5f9..ad9726b 100644
--- a/server/dispatcher.c
+++ b/server/dispatcher.c
@@ -136,7 +136,7 @@ static int dispatcher_handle_single_read(Dispatcher *dispatcher)
         return 0;
     }
     if (msg->handler) {
-        msg->handler(dispatcher->opaque, (void *)payload);
+        msg->handler(dispatcher->opaque, type, (void *)payload);
     } else {
         spice_printerr("error: no handler for message type %d", type);
     }
diff --git a/server/dispatcher.h b/server/dispatcher.h
index 1b389bd..85cbd26 100644
--- a/server/dispatcher.h
+++ b/server/dispatcher.h
@@ -6,6 +6,7 @@
 typedef struct Dispatcher Dispatcher;
 
 typedef void (*dispatcher_handle_message)(void *opaque,
+                                          uint32_t message_type,
                                           void *payload);
 
 typedef void (*dispatcher_handle_async_done)(void *opaque,
diff --git a/server/main_dispatcher.c b/server/main_dispatcher.c
index dbe1037..ad81e42 100644
--- a/server/main_dispatcher.c
+++ b/server/main_dispatcher.c
@@ -73,6 +73,7 @@ static void main_dispatcher_self_handle_channel_event(
 }
 
 static void main_dispatcher_handle_channel_event(void *opaque,
+                                                 uint32_t message_type,
                                                  void *payload)
 {
     MainDispatcherChannelEventMessage *channel_event = payload;
@@ -97,6 +98,7 @@ void main_dispatcher_channel_event(int event, SpiceChannelEventInfo *info)
 
 
 static void main_dispatcher_handle_migrate_complete(void *opaque,
+                                                    uint32_t message_type,
                                                     void *payload)
 {
     MainDispatcherMigrateSeamlessDstCompleteMessage *mig_complete = payload;
@@ -106,6 +108,7 @@ static void main_dispatcher_handle_migrate_complete(void *opaque,
 }
 
 static void main_dispatcher_handle_mm_time_latency(void *opaque,
+                                                   uint32_t message_type,
                                                    void *payload)
 {
     MainDispatcherMmTimeLatencyMessage *msg = payload;
@@ -114,6 +117,7 @@ static void main_dispatcher_handle_mm_time_latency(void *opaque,
 }
 
 static void main_dispatcher_handle_client_disconnect(void *opaque,
+                                                     uint32_t message_type,
                                                      void *payload)
 {
     MainDispatcherClientDisconnectMessage *msg = payload;
diff --git a/server/red_worker.c b/server/red_worker.c
index 1655bbe..20dc1d7 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -11011,7 +11011,7 @@ static void surface_dirty_region_to_rects(RedSurface *surface,
     free(dirty_rects);
 }
 
-void handle_dev_update_async(void *opaque, void *payload)
+void handle_dev_update_async(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorker *worker = opaque;
     RedWorkerMessageUpdateAsync *msg = payload;
@@ -11046,7 +11046,7 @@ void handle_dev_update_async(void *opaque, void *payload)
     free(qxl_dirty_rects);
 }
 
-void handle_dev_update(void *opaque, void *payload)
+void handle_dev_update(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorker *worker = opaque;
     RedWorkerMessageUpdate *msg = payload;
@@ -11082,7 +11082,7 @@ static void dev_add_memslot(RedWorker *worker, QXLDevMemSlot mem_slot)
                               mem_slot.generation);
 }
 
-void handle_dev_add_memslot(void *opaque, void *payload)
+void handle_dev_add_memslot(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorker *worker = opaque;
     RedWorkerMessageAddMemslot *msg = payload;
@@ -11093,7 +11093,7 @@ void handle_dev_add_memslot(void *opaque, void *payload)
                               mem_slot.generation);
 }
 
-void handle_dev_del_memslot(void *opaque, void *payload)
+void handle_dev_del_memslot(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorker *worker = opaque;
     RedWorkerMessageDelMemslot *msg = payload;
@@ -11130,7 +11130,7 @@ static void dev_destroy_surface_wait(RedWorker *worker, uint32_t surface_id)
     }
 }
 
-void handle_dev_destroy_surface_wait(void *opaque, void *payload)
+void handle_dev_destroy_surface_wait(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorkerMessageDestroySurfaceWait *msg = payload;
     RedWorker *worker = opaque;
@@ -11205,7 +11205,7 @@ static inline void dev_destroy_surfaces(RedWorker *worker)
     red_cursor_reset(worker);
 }
 
-void handle_dev_destroy_surfaces(void *opaque, void *payload)
+void handle_dev_destroy_surfaces(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorker *worker = opaque;
 
@@ -11362,7 +11362,7 @@ static void dev_create_primary_surface(RedWorker *worker, uint32_t surface_id,
     }
 }
 
-void handle_dev_create_primary_surface(void *opaque, void *payload)
+void handle_dev_create_primary_surface(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorkerMessageCreatePrimarySurface *msg = payload;
     RedWorker *worker = opaque;
@@ -11390,7 +11390,7 @@ static void dev_destroy_primary_surface(RedWorker *worker, uint32_t surface_id)
     red_cursor_reset(worker);
 }
 
-void handle_dev_destroy_primary_surface(void *opaque, void *payload)
+void handle_dev_destroy_primary_surface(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorkerMessageDestroyPrimarySurface *msg = payload;
     RedWorker *worker = opaque;
@@ -11399,7 +11399,7 @@ void handle_dev_destroy_primary_surface(void *opaque, void *payload)
     dev_destroy_primary_surface(worker, surface_id);
 }
 
-void handle_dev_destroy_primary_surface_async(void *opaque, void *payload)
+void handle_dev_destroy_primary_surface_async(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorkerMessageDestroyPrimarySurfaceAsync *msg = payload;
     RedWorker *worker = opaque;
@@ -11425,21 +11425,21 @@ static void dev_flush_surfaces(RedWorker *worker)
     flush_all_surfaces(worker);
 }
 
-void handle_dev_flush_surfaces(void *opaque, void *payload)
+void handle_dev_flush_surfaces(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorker *worker = opaque;
 
     dev_flush_surfaces(worker);
 }
 
-void handle_dev_flush_surfaces_async(void *opaque, void *payload)
+void handle_dev_flush_surfaces_async(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorker *worker = opaque;
 
     dev_flush_surfaces(worker);
 }
 
-void handle_dev_stop(void *opaque, void *payload)
+void handle_dev_stop(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorker *worker = opaque;
 
@@ -11496,7 +11496,7 @@ static int display_channel_wait_for_migrate_data(DisplayChannel *display)
     return FALSE;
 }
 
-void handle_dev_start(void *opaque, void *payload)
+void handle_dev_start(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorker *worker = opaque;
 
@@ -11514,7 +11514,7 @@ void handle_dev_start(void *opaque, void *payload)
     guest_set_client_capabilities(worker);
 }
 
-void handle_dev_wakeup(void *opaque, void *payload)
+void handle_dev_wakeup(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorker *worker = opaque;
 
@@ -11522,7 +11522,7 @@ void handle_dev_wakeup(void *opaque, void *payload)
     stat_inc_counter(worker->wakeup_counter, 1);
 }
 
-void handle_dev_oom(void *opaque, void *payload)
+void handle_dev_oom(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorker *worker = opaque;
 
@@ -11555,17 +11555,17 @@ void handle_dev_oom(void *opaque, void *payload)
     clear_bit(RED_WORKER_PENDING_OOM, worker->pending);
 }
 
-void handle_dev_reset_cursor(void *opaque, void *payload)
+void handle_dev_reset_cursor(void *opaque, uint32_t message_type, void *payload)
 {
     red_cursor_reset((RedWorker *)opaque);
 }
 
-void handle_dev_reset_image_cache(void *opaque, void *payload)
+void handle_dev_reset_image_cache(void *opaque, uint32_t message_type, void *payload)
 {
     image_cache_reset(&((RedWorker *)opaque)->image_cache);
 }
 
-void handle_dev_destroy_surface_wait_async(void *opaque, void *payload)
+void handle_dev_destroy_surface_wait_async(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorkerMessageDestroySurfaceWaitAsync *msg = payload;
     RedWorker *worker = opaque;
@@ -11573,14 +11573,14 @@ void handle_dev_destroy_surface_wait_async(void *opaque, void *payload)
     dev_destroy_surface_wait(worker, msg->surface_id);
 }
 
-void handle_dev_destroy_surfaces_async(void *opaque, void *payload)
+void handle_dev_destroy_surfaces_async(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorker *worker = opaque;
 
     dev_destroy_surfaces(worker);
 }
 
-void handle_dev_create_primary_surface_async(void *opaque, void *payload)
+void handle_dev_create_primary_surface_async(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorkerMessageCreatePrimarySurfaceAsync *msg = payload;
     RedWorker *worker = opaque;
@@ -11594,7 +11594,7 @@ void handle_dev_create_primary_surface_async(void *opaque, void *payload)
  * pthread is created, since the channel duration is the lifetime of the spice
  * server. */
 
-void handle_dev_display_channel_create(void *opaque, void *payload)
+void handle_dev_display_channel_create(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorker *worker = opaque;
 
@@ -11605,7 +11605,7 @@ void handle_dev_display_channel_create(void *opaque, void *payload)
     send_data(worker->channel, &red_channel, sizeof(RedChannel *));
 }
 
-void handle_dev_display_connect(void *opaque, void *payload)
+void handle_dev_display_connect(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorkerMessageDisplayConnect *msg = payload;
     RedWorker *worker = opaque;
@@ -11621,7 +11621,7 @@ void handle_dev_display_connect(void *opaque, void *payload)
     free(msg->common_caps);
 }
 
-void handle_dev_display_disconnect(void *opaque, void *payload)
+void handle_dev_display_disconnect(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorkerMessageDisplayDisconnect *msg = payload;
     RedChannelClient *rcc = msg->rcc;
@@ -11635,7 +11635,7 @@ void handle_dev_display_disconnect(void *opaque, void *payload)
     red_channel_client_disconnect(rcc);
 }
 
-void handle_dev_display_migrate(void *opaque, void *payload)
+void handle_dev_display_migrate(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorkerMessageDisplayMigrate *msg = payload;
     RedWorker *worker = opaque;
@@ -11646,7 +11646,9 @@ void handle_dev_display_migrate(void *opaque, void *payload)
     red_migrate_display(worker, rcc);
 }
 
-static void handle_dev_monitors_config_async(void *opaque, void *payload)
+static void handle_dev_monitors_config_async(void *opaque,
+                                             uint32_t message_type,
+                                             void *payload)
 {
     RedWorkerMessageMonitorsConfigAsync *msg = payload;
     RedWorker *worker = opaque;
@@ -11677,7 +11679,7 @@ static void handle_dev_monitors_config_async(void *opaque, void *payload)
 }
 
 /* TODO: special, perhaps use another dispatcher? */
-void handle_dev_cursor_channel_create(void *opaque, void *payload)
+void handle_dev_cursor_channel_create(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorker *worker = opaque;
     RedChannel *red_channel;
@@ -11688,7 +11690,7 @@ void handle_dev_cursor_channel_create(void *opaque, void *payload)
     send_data(worker->channel, &red_channel, sizeof(RedChannel *));
 }
 
-void handle_dev_cursor_connect(void *opaque, void *payload)
+void handle_dev_cursor_connect(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorkerMessageCursorConnect *msg = payload;
     RedWorker *worker = opaque;
@@ -11704,7 +11706,7 @@ void handle_dev_cursor_connect(void *opaque, void *payload)
     free(msg->common_caps);
 }
 
-void handle_dev_cursor_disconnect(void *opaque, void *payload)
+void handle_dev_cursor_disconnect(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorkerMessageCursorDisconnect *msg = payload;
     RedChannelClient *rcc = msg->rcc;
@@ -11714,7 +11716,7 @@ void handle_dev_cursor_disconnect(void *opaque, void *payload)
     red_channel_client_disconnect(rcc);
 }
 
-void handle_dev_cursor_migrate(void *opaque, void *payload)
+void handle_dev_cursor_migrate(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorkerMessageCursorMigrate *msg = payload;
     RedWorker *worker = opaque;
@@ -11725,7 +11727,7 @@ void handle_dev_cursor_migrate(void *opaque, void *payload)
     red_migrate_cursor(worker, rcc);
 }
 
-void handle_dev_set_compression(void *opaque, void *payload)
+void handle_dev_set_compression(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorkerMessageSetCompression *msg = payload;
     RedWorker *worker = opaque;
@@ -11772,7 +11774,7 @@ void handle_dev_set_compression(void *opaque, void *payload)
 #endif
 }
 
-void handle_dev_set_streaming_video(void *opaque, void *payload)
+void handle_dev_set_streaming_video(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorkerMessageSetStreamingVideo *msg = payload;
     RedWorker *worker = opaque;
@@ -11794,7 +11796,7 @@ void handle_dev_set_streaming_video(void *opaque, void *payload)
     }
 }
 
-void handle_dev_set_mouse_mode(void *opaque, void *payload)
+void handle_dev_set_mouse_mode(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorkerMessageSetMouseMode *msg = payload;
     RedWorker *worker = opaque;
@@ -11803,7 +11805,7 @@ void handle_dev_set_mouse_mode(void *opaque, void *payload)
     spice_info("mouse mode %u", worker->mouse_mode);
 }
 
-void handle_dev_add_memslot_async(void *opaque, void *payload)
+void handle_dev_add_memslot_async(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorkerMessageAddMemslotAsync *msg = payload;
     RedWorker *worker = opaque;
@@ -11811,14 +11813,14 @@ void handle_dev_add_memslot_async(void *opaque, void *payload)
     dev_add_memslot(worker, msg->mem_slot);
 }
 
-void handle_dev_reset_memslots(void *opaque, void *payload)
+void handle_dev_reset_memslots(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorker *worker = opaque;
 
     red_memslot_info_reset(&worker->mem_slots);
 }
 
-void handle_dev_driver_unload(void *opaque, void *payload)
+void handle_dev_driver_unload(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorker *worker = opaque;
 
@@ -11854,7 +11856,7 @@ static int loadvm_command(RedWorker *worker, QXLCommandExt *ext)
     return TRUE;
 }
 
-void handle_dev_loadvm_commands(void *opaque, void *payload)
+void handle_dev_loadvm_commands(void *opaque, uint32_t message_type, void *payload)
 {
     RedWorkerMessageLoadvmCommands *msg = payload;
     RedWorker *worker = opaque;
-- 
2.4.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]