mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2025-12-27 07:29:32 +00:00
server/red_channel: add hold_item (from red_worker)
hold_item called on init_send_data, matching release. This is not the behavior of red_worker - we ref++ (==hold_item) when sending the item, and --refs when releasing it, instead of only holding if the send is blocked. Note 1: Naming: hold_pipe_item is the proc name, the variable is called hold_item, this is similar to release_item/release_pipe_item naming. Note 2: All channels have empty implementation, we later use this when red_worker get's RedChannelized.
This commit is contained in:
parent
e571b5ebbb
commit
7dfd7a0c77
@ -508,6 +508,10 @@ static int inputs_channel_config_socket(RedChannel *channel)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void inputs_channel_hold_pipe_item(PipeItem *item)
|
||||
{
|
||||
}
|
||||
|
||||
static void inputs_link(Channel *channel, RedsStreamContext *peer, int migration,
|
||||
int num_common_caps, uint32_t *common_caps, int num_caps,
|
||||
uint32_t *caps)
|
||||
@ -523,6 +527,7 @@ static void inputs_link(Channel *channel, RedsStreamContext *peer, int migration
|
||||
,inputs_channel_handle_parsed
|
||||
,inputs_channel_alloc_msg_rcv_buf
|
||||
,inputs_channel_release_msg_rcv_buf
|
||||
,inputs_channel_hold_pipe_item
|
||||
,inputs_channel_send_item
|
||||
,inputs_channel_release_pipe_item
|
||||
,inputs_channel_on_incoming_error
|
||||
|
||||
@ -776,6 +776,10 @@ static int main_channel_config_socket(RedChannel *channel)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void main_channel_hold_pipe_item(PipeItem *item)
|
||||
{
|
||||
}
|
||||
|
||||
static void main_channel_link(Channel *channel, RedsStreamContext *peer, int migration,
|
||||
int num_common_caps, uint32_t *common_caps, int num_caps,
|
||||
uint32_t *caps)
|
||||
@ -791,6 +795,7 @@ static void main_channel_link(Channel *channel, RedsStreamContext *peer, int mig
|
||||
,main_channel_handle_parsed
|
||||
,main_channel_alloc_msg_rcv_buf
|
||||
,main_channel_release_msg_rcv_buf
|
||||
,main_channel_hold_pipe_item
|
||||
,main_channel_send_item
|
||||
,main_channel_release_pipe_item
|
||||
,main_channel_on_error
|
||||
|
||||
@ -224,6 +224,7 @@ static void red_channel_peer_prepare_out_msg(void *opaque, struct iovec *vec, in
|
||||
static void red_channel_peer_on_out_block(void *opaque)
|
||||
{
|
||||
RedChannel *channel = (RedChannel *)opaque;
|
||||
|
||||
channel->send_data.blocked = TRUE;
|
||||
channel->core->watch_update_mask(channel->peer->watch,
|
||||
SPICE_WATCH_EVENT_READ |
|
||||
@ -253,6 +254,7 @@ RedChannel *red_channel_create(int size, RedsStreamContext *peer,
|
||||
channel_handle_message_proc handle_message,
|
||||
channel_alloc_msg_recv_buf_proc alloc_recv_buf,
|
||||
channel_release_msg_recv_buf_proc release_recv_buf,
|
||||
channel_hold_pipe_item_proc hold_item,
|
||||
channel_send_pipe_item_proc send_item,
|
||||
channel_release_pipe_item_proc release_item)
|
||||
{
|
||||
@ -267,6 +269,7 @@ RedChannel *red_channel_create(int size, RedsStreamContext *peer,
|
||||
channel->disconnect = disconnect;
|
||||
channel->send_item = send_item;
|
||||
channel->release_item = release_item;
|
||||
channel->hold_item = hold_item;
|
||||
|
||||
channel->peer = peer;
|
||||
channel->core = core;
|
||||
@ -332,6 +335,7 @@ RedChannel *red_channel_create_parser(int size, RedsStreamContext *peer,
|
||||
channel_handle_parsed_proc handle_parsed,
|
||||
channel_alloc_msg_recv_buf_proc alloc_recv_buf,
|
||||
channel_release_msg_recv_buf_proc release_recv_buf,
|
||||
channel_hold_pipe_item_proc hold_item,
|
||||
channel_send_pipe_item_proc send_item,
|
||||
channel_release_pipe_item_proc release_item,
|
||||
channel_on_incoming_error_proc incoming_error,
|
||||
@ -339,7 +343,7 @@ RedChannel *red_channel_create_parser(int size, RedsStreamContext *peer,
|
||||
{
|
||||
RedChannel *channel = red_channel_create(size, peer,
|
||||
core, migrate, handle_acks, config_socket, do_nothing_disconnect, do_nothing_handle_message,
|
||||
alloc_recv_buf, release_recv_buf, send_item, release_item);
|
||||
alloc_recv_buf, release_recv_buf, hold_item, send_item, release_item);
|
||||
|
||||
if (channel == NULL) {
|
||||
return NULL;
|
||||
@ -439,7 +443,11 @@ void red_channel_reset_send_data(RedChannel *channel)
|
||||
void red_channel_init_send_data(RedChannel *channel, uint16_t msg_type, PipeItem *item)
|
||||
{
|
||||
channel->send_data.header->type = msg_type;
|
||||
channel->send_data.item = item;
|
||||
if (item) {
|
||||
ASSERT(channel->send_data.item == NULL);
|
||||
channel->send_data.item = item;
|
||||
channel->hold_item(item);
|
||||
}
|
||||
}
|
||||
|
||||
static void red_channel_send(RedChannel *channel)
|
||||
|
||||
@ -107,6 +107,7 @@ typedef void (*channel_release_msg_recv_buf_proc)(RedChannel *channel,
|
||||
typedef void (*channel_disconnect_proc)(RedChannel *channel);
|
||||
typedef int (*channel_configure_socket_proc)(RedChannel *channel);
|
||||
typedef void (*channel_send_pipe_item_proc)(RedChannel *channel, PipeItem *item);
|
||||
typedef void (*channel_hold_pipe_item_proc)(PipeItem *item);
|
||||
typedef void (*channel_release_pipe_item_proc)(RedChannel *channel,
|
||||
PipeItem *item, int item_pushed);
|
||||
typedef void (*channel_on_incoming_error_proc)(RedChannel *channel);
|
||||
@ -145,6 +146,7 @@ struct RedChannel {
|
||||
|
||||
channel_disconnect_proc disconnect;
|
||||
channel_send_pipe_item_proc send_item;
|
||||
channel_hold_pipe_item_proc hold_item;
|
||||
channel_release_pipe_item_proc release_item;
|
||||
|
||||
int during_send;
|
||||
@ -165,6 +167,7 @@ RedChannel *red_channel_create(int size, RedsStreamContext *peer,
|
||||
channel_handle_message_proc handle_message,
|
||||
channel_alloc_msg_recv_buf_proc alloc_recv_buf,
|
||||
channel_release_msg_recv_buf_proc release_recv_buf,
|
||||
channel_hold_pipe_item_proc hold_item,
|
||||
channel_send_pipe_item_proc send_item,
|
||||
channel_release_pipe_item_proc release_item);
|
||||
|
||||
@ -178,6 +181,7 @@ RedChannel *red_channel_create_parser(int size, RedsStreamContext *peer,
|
||||
channel_handle_parsed_proc handle_parsed,
|
||||
channel_alloc_msg_recv_buf_proc alloc_recv_buf,
|
||||
channel_release_msg_recv_buf_proc release_recv_buf,
|
||||
channel_hold_pipe_item_proc hold_item,
|
||||
channel_send_pipe_item_proc send_item,
|
||||
channel_release_pipe_item_proc release_item,
|
||||
channel_on_incoming_error_proc incoming_error,
|
||||
|
||||
@ -3420,6 +3420,10 @@ static void on_new_tunnel_channel(TunnelChannel *channel)
|
||||
}
|
||||
}
|
||||
|
||||
static void tunnel_channel_hold_pipe_item(PipeItem *item)
|
||||
{
|
||||
}
|
||||
|
||||
static void handle_tunnel_channel_link(Channel *channel, RedsStreamContext *peer, int migration,
|
||||
int num_common_caps, uint32_t *common_caps, int num_caps,
|
||||
uint32_t *caps)
|
||||
@ -3438,6 +3442,7 @@ static void handle_tunnel_channel_link(Channel *channel, RedsStreamContext *peer
|
||||
tunnel_channel_handle_message,
|
||||
tunnel_channel_alloc_msg_rcv_buf,
|
||||
tunnel_channel_release_msg_rcv_buf,
|
||||
tunnel_channel_hold_pipe_item,
|
||||
tunnel_channel_send_item,
|
||||
tunnel_channel_release_pipe_item);
|
||||
|
||||
|
||||
@ -347,7 +347,7 @@ typedef struct LocalCursor {
|
||||
|
||||
typedef struct RedChannel RedChannel;
|
||||
typedef void (*disconnect_channel_proc)(RedChannel *channel);
|
||||
typedef void (*hold_item_proc)(void *item);
|
||||
typedef void (*hold_pipe_item_proc)(void *item);
|
||||
typedef void (*release_item_proc)(RedChannel *channel, void *item);
|
||||
typedef int (*handle_message_proc)(RedChannel *channel, size_t size, uint32_t type, void *message);
|
||||
|
||||
@ -385,7 +385,7 @@ struct RedChannel {
|
||||
} recive_data;
|
||||
|
||||
disconnect_channel_proc disconnect;
|
||||
hold_item_proc hold_item;
|
||||
hold_pipe_item_proc hold_item;
|
||||
release_item_proc release_item;
|
||||
handle_message_proc handle_message;
|
||||
#ifdef RED_STATISTICS
|
||||
@ -9310,7 +9310,7 @@ static RedChannel *__new_channel(RedWorker *worker, int size, uint32_t channel_i
|
||||
RedsStreamContext *peer, int migrate,
|
||||
event_listener_action_proc handler,
|
||||
disconnect_channel_proc disconnect,
|
||||
hold_item_proc hold_item,
|
||||
hold_pipe_item_proc hold_item,
|
||||
release_item_proc release_item,
|
||||
handle_message_proc handle_message)
|
||||
{
|
||||
@ -9389,7 +9389,7 @@ static void handle_channel_events(EventListener *in_listener, uint32_t events)
|
||||
}
|
||||
}
|
||||
|
||||
static void display_channel_hold_item(void *item)
|
||||
static void display_channel_hold_pipe_item(void *item)
|
||||
{
|
||||
ASSERT(item);
|
||||
switch (((PipeItem *)item)->type) {
|
||||
@ -9444,7 +9444,7 @@ static void handle_new_display_channel(RedWorker *worker, RedsStreamContext *pee
|
||||
SPICE_CHANNEL_DISPLAY, peer,
|
||||
migrate, handle_channel_events,
|
||||
red_disconnect_display,
|
||||
display_channel_hold_item,
|
||||
display_channel_hold_pipe_item,
|
||||
display_channel_release_item,
|
||||
display_channel_handle_message))) {
|
||||
return;
|
||||
@ -9544,7 +9544,7 @@ static void on_new_cursor_channel(RedWorker *worker)
|
||||
}
|
||||
}
|
||||
|
||||
static void cursor_channel_hold_item(void *item)
|
||||
static void cursor_channel_hold_pipe_item(void *item)
|
||||
{
|
||||
ASSERT(item);
|
||||
((CursorItem *)item)->refs++;
|
||||
@ -9566,7 +9566,7 @@ static void red_connect_cursor(RedWorker *worker, RedsStreamContext *peer, int m
|
||||
SPICE_CHANNEL_CURSOR, peer, migrate,
|
||||
handle_channel_events,
|
||||
red_disconnect_cursor,
|
||||
cursor_channel_hold_item,
|
||||
cursor_channel_hold_pipe_item,
|
||||
cursor_channel_release_item,
|
||||
channel_handle_message))) {
|
||||
return;
|
||||
|
||||
@ -485,6 +485,10 @@ static int smartcard_channel_handle_message(RedChannel *channel, SpiceDataHeader
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void smartcard_channel_hold_pipe_item(PipeItem *item)
|
||||
{
|
||||
}
|
||||
|
||||
static void smartcard_link(Channel *channel, RedsStreamContext *peer,
|
||||
int migration, int num_common_caps,
|
||||
uint32_t *common_caps, int num_caps,
|
||||
@ -502,6 +506,7 @@ static void smartcard_link(Channel *channel, RedsStreamContext *peer,
|
||||
smartcard_channel_handle_message,
|
||||
smartcard_channel_alloc_msg_rcv_buf,
|
||||
smartcard_channel_release_msg_rcv_buf,
|
||||
smartcard_channel_hold_pipe_item,
|
||||
smartcard_channel_send_item,
|
||||
smartcard_channel_release_pipe_item);
|
||||
if (!g_smartcard_channel) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user