[Spice-devel] [PATCH spice 05/10] server/red_worker: when SPICE_MSG_LIST will contain only one msg, send this message instead of the list
Yonit Halperin
yhalperi at redhat.com
Wed Dec 28 09:15:14 PST 2011
In the above cases, this behavior will decrease the difference between
using a header without sub list and a one with sub list to 4 bytes.
---
server/red_worker.c | 27 ++++++++++++++++++---------
1 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/server/red_worker.c b/server/red_worker.c
index bbcd891..c7da1a6 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -7805,12 +7805,28 @@ static inline void display_begin_send_message(RedChannelClient *rcc)
int sync_count = 0;
int i;
+ for (i = 0; i < MAX_CACHE_CLIENTS; i++) {
+ if (i != dcc->common.id && free_list->sync[i] != 0) {
+ free_list->wait.header.wait_list[sync_count].channel_type = SPICE_CHANNEL_DISPLAY;
+ free_list->wait.header.wait_list[sync_count].channel_id = i;
+ free_list->wait.header.wait_list[sync_count++].message_serial = free_list->sync[i];
+ }
+ }
+ free_list->wait.header.wait_count = sync_count;
+
if (rcc->is_header_with_sub) {
urgent_marshaller = red_channel_client_get_marshaller(rcc);
} else {
urgent_marshaller = red_channel_client_switch_to_urgent_sender(rcc);
- red_channel_client_init_send_data(rcc, SPICE_MSG_LIST, NULL);
+ if (sync_count) {
+ red_channel_client_init_send_data(rcc, SPICE_MSG_LIST, NULL);
+ } else { /* only one message, no need for a list */
+ red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_INVAL_LIST, NULL);
+ spice_marshall_msg_display_inval_list(urgent_marshaller, free_list->res);
+ goto end;
+ }
}
+
inval_m = spice_marshaller_get_submarshaller(urgent_marshaller);
/* type + size + submessage */
@@ -7819,14 +7835,6 @@ static inline void display_begin_send_message(RedChannelClient *rcc)
free_list->res->count * sizeof(free_list->res->resources[0]));
spice_marshall_msg_display_inval_list(inval_m, free_list->res);
- for (i = 0; i < MAX_CACHE_CLIENTS; i++) {
- if (i != dcc->common.id && free_list->sync[i] != 0) {
- free_list->wait.header.wait_list[sync_count].channel_type = SPICE_CHANNEL_DISPLAY;
- free_list->wait.header.wait_list[sync_count].channel_id = i;
- free_list->wait.header.wait_list[sync_count++].message_serial = free_list->sync[i];
- }
- }
- free_list->wait.header.wait_count = sync_count;
if (sync_count) {
int j;
@@ -7873,6 +7881,7 @@ static inline void display_begin_send_message(RedChannelClient *rcc)
header->sub_list = spice_marshaller_get_offset(sub_list_m);
}
}
+end:
red_channel_client_begin_send_message(rcc);
}
--
1.7.6.4
More information about the Spice-devel
mailing list