From ef4b1bdb27f32e10556249c959ae3a42ef882b1a Mon Sep 17 00:00:00 2001 From: Frediano Ziglio Date: Mon, 11 Sep 2017 21:23:04 +0100 Subject: [PATCH] red-channel-client: Prevent too tight loop waiting for ACKs RedChannelClient has a "handle-acks" feature. If this feature is enabled, after the configured number of messages it waits for an ACK from the client. If is waiting for an ACK it stops sending messages. However the write notification was not disabled, causing the loop event to always trigger, as the socket in this case is ready to accept data. Specifically red_channel_client_event is continuously called. This is noticeable using slow network environments and having some additional loop instrumentation. Signed-off-by: Frediano Ziglio Acked-by: Christophe Fergeau --- server/red-channel-client.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/red-channel-client.c b/server/red-channel-client.c index 82a2837f..a8c6f33f 100644 --- a/server/red-channel-client.c +++ b/server/red-channel-client.c @@ -1327,7 +1327,8 @@ void red_channel_client_push(RedChannelClient *rcc) while ((pipe_item = red_channel_client_pipe_item_get(rcc))) { red_channel_client_send_item(rcc, pipe_item); } - if (red_channel_client_no_item_being_sent(rcc) && g_queue_is_empty(&rcc->priv->pipe)) { + if ((red_channel_client_no_item_being_sent(rcc) && g_queue_is_empty(&rcc->priv->pipe)) || + red_channel_client_waiting_for_ack(rcc)) { red_channel_client_watch_update_mask(rcc, SPICE_WATCH_EVENT_READ); } rcc->priv->during_send = FALSE; @@ -1452,6 +1453,8 @@ bool red_channel_client_handle_message(RedChannelClient *rcc, uint16_t type, case SPICE_MSGC_ACK: if (rcc->priv->ack_data.client_generation == rcc->priv->ack_data.generation) { rcc->priv->ack_data.messages_window -= rcc->priv->ack_data.client_window; + red_channel_client_watch_update_mask(rcc, + SPICE_WATCH_EVENT_READ|SPICE_WATCH_EVENT_WRITE); red_channel_client_push(rcc); } break;