Remove red_pipe_add_verb family function

These functions were implementing the same stuff as empty
messages functions provided by RedChannel so reuse them.

The implementation seems a bit different but the result
is the same. Specifically:
- RedEmptyMsgPipeItem::msg is int while RedVerbItem::verb was
  uint16_t however this data goes into the message type which
  is uint16_t (a 16 bit on the network protocol);
- red_channel_client_send_empty_msg calls
  red_channel_client_begin_send_message while red_marshall_verb
  does not. However red_marshall_verb is called only by
  cursor_channel_send_item and dcc_send_item which always
  calls red_channel_client_begin_send_message.
  Note that in dcc_send_item when an empty message is sent
  red_channel_client_send_message_pending always returns
  true;
- when a PipeItem is created red_channel_client_pipe_add_empty_msg
  calls red_channel_client_push while red_pipe_add_verb does not.
  This actually make very little difference as this kind of item are
  never removed from the queue and a push is forced in every case
  running the event handler for the stream watch (see
  prepare_pipe_add and red_channel_client_event).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
Frediano Ziglio 2016-09-26 08:59:39 +01:00
parent ed9d759ba4
commit c5059edb82
6 changed files with 6 additions and 44 deletions

View File

@ -65,43 +65,11 @@ gboolean common_graphics_channel_get_during_target_migrate(CommonGraphicsChannel
QXLInstance* common_graphics_channel_get_qxl(CommonGraphicsChannel *self);
enum {
RED_PIPE_ITEM_TYPE_VERB = RED_PIPE_ITEM_TYPE_CHANNEL_BASE,
RED_PIPE_ITEM_TYPE_INVAL_ONE,
RED_PIPE_ITEM_TYPE_INVAL_ONE = RED_PIPE_ITEM_TYPE_CHANNEL_BASE,
RED_PIPE_ITEM_TYPE_COMMON_LAST
};
typedef struct RedVerbItem {
RedPipeItem base;
uint16_t verb;
} RedVerbItem;
static inline void red_marshall_verb(RedChannelClient *rcc, RedVerbItem *item)
{
red_channel_client_init_send_data(rcc, item->verb, NULL);
}
static inline void red_pipe_add_verb(RedChannelClient* rcc, uint16_t verb)
{
RedVerbItem *item = spice_new(RedVerbItem, 1);
red_pipe_item_init(&item->base, RED_PIPE_ITEM_TYPE_VERB);
item->verb = verb;
red_channel_client_pipe_add(rcc, &item->base);
}
static inline void red_pipe_add_verb_proxy(RedChannelClient *rcc, gpointer data)
{
uint16_t verb = GPOINTER_TO_UINT(data);
red_pipe_add_verb(rcc, verb);
}
static inline void red_pipes_add_verb(RedChannel *channel, uint16_t verb)
{
red_channel_apply_clients_data(channel, red_pipe_add_verb_proxy, GUINT_TO_POINTER(verb));
}
G_END_DECLS
#endif /* _COMMON_GRAPHICS_CHANNEL_H */

View File

@ -286,9 +286,6 @@ static void cursor_channel_send_item(RedChannelClient *rcc, RedPipeItem *pipe_it
case RED_PIPE_ITEM_TYPE_INVAL_ONE:
red_marshall_inval(rcc, m, SPICE_CONTAINEROF(pipe_item, RedCacheItem, u.pipe_data));
break;
case RED_PIPE_ITEM_TYPE_VERB:
red_marshall_verb(rcc, SPICE_UPCAST(RedVerbItem, pipe_item));
break;
case RED_PIPE_ITEM_TYPE_CURSOR_INIT:
cursor_channel_client_reset_cursor_cache(rcc);
red_marshall_cursor_init(ccc, m, pipe_item);
@ -378,7 +375,7 @@ void cursor_channel_reset(CursorChannel *cursor)
if (red_channel_is_connected(channel)) {
red_channel_pipes_add_type(channel, RED_PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE);
if (!common_graphics_channel_get_during_target_migrate(COMMON_GRAPHICS_CHANNEL(cursor))) {
red_pipes_add_verb(channel, SPICE_MSG_CURSOR_RESET);
red_channel_pipes_add_empty_msg(channel, SPICE_MSG_CURSOR_RESET);
}
if (!red_channel_wait_all_sent(channel,
COMMON_CLIENT_TIMEOUT)) {

View File

@ -2399,9 +2399,6 @@ void dcc_send_item(RedChannelClient *rcc, RedPipeItem *pipe_item)
case RED_PIPE_ITEM_TYPE_UPGRADE:
marshall_upgrade(rcc, m, SPICE_UPCAST(RedUpgradeItem, pipe_item));
break;
case RED_PIPE_ITEM_TYPE_VERB:
red_marshall_verb(rcc, SPICE_UPCAST(RedVerbItem, pipe_item));
break;
case RED_PIPE_ITEM_TYPE_MIGRATE_DATA:
display_channel_marshall_migrate_data(rcc, m);
break;

View File

@ -588,7 +588,7 @@ void dcc_start(DisplayChannelClient *dcc)
dcc_create_surface(dcc, 0);
dcc_push_surface_image(dcc, 0);
dcc_push_monitors_config(dcc);
red_pipe_add_verb(rcc, SPICE_MSG_DISPLAY_MARK);
red_channel_client_pipe_add_empty_msg(rcc, SPICE_MSG_DISPLAY_MARK);
dcc_create_all_streams(dcc);
}

View File

@ -1832,7 +1832,7 @@ void display_channel_destroy_surfaces(DisplayChannel *display)
if (red_channel_is_connected(RED_CHANNEL(display))) {
red_channel_pipes_add_type(RED_CHANNEL(display), RED_PIPE_ITEM_TYPE_INVAL_PALETTE_CACHE);
red_pipes_add_verb(RED_CHANNEL(display), SPICE_MSG_DISPLAY_STREAM_DESTROY_ALL);
red_channel_pipes_add_empty_msg(RED_CHANNEL(display), SPICE_MSG_DISPLAY_STREAM_DESTROY_ALL);
}
display_channel_free_glz_drawables(display);

View File

@ -537,8 +537,8 @@ static void dev_create_primary_surface(RedWorker *worker, uint32_t surface_id,
if (!worker->driver_cap_monitors_config) {
red_worker_push_monitors_config(worker);
}
red_pipes_add_verb(RED_CHANNEL(worker->display_channel),
SPICE_MSG_DISPLAY_MARK);
red_channel_pipes_add_empty_msg(RED_CHANNEL(worker->display_channel),
SPICE_MSG_DISPLAY_MARK);
red_channel_push(RED_CHANNEL(worker->display_channel));
}