[Spice-commits] 2 commits - server/char-device.c server/common-graphics-channel.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jun 10 12:45:13 UTC 2019


 server/char-device.c             |   27 ++++++++-------------------
 server/common-graphics-channel.c |    2 +-
 2 files changed, 9 insertions(+), 20 deletions(-)

New commits:
commit 581a2d0f68366cd25a092356d05b238e46c4c986
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Thu Aug 31 07:48:32 2017 +0100

    char-device: Reuse macros to scan GList
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/server/char-device.c b/server/char-device.c
index 9ee25566..caabdd3e 100644
--- a/server/char-device.c
+++ b/server/char-device.c
@@ -224,11 +224,9 @@ static void red_char_device_handle_client_overflow(RedCharDeviceClient *dev_clie
 static RedCharDeviceClient *red_char_device_client_find(RedCharDevice *dev,
                                                         RedClient *client)
 {
-    GList *item;
-
-    for (item = dev->priv->clients; item != NULL; item = item->next) {
-        RedCharDeviceClient *dev_client = item->data;
+    RedCharDeviceClient *dev_client;
 
+    GLIST_FOREACH(dev->priv->clients, RedCharDeviceClient, dev_client) {
         if (dev_client->client == client) {
             return dev_client;
         }
@@ -254,12 +252,10 @@ static int red_char_device_can_send_to_client(RedCharDeviceClient *dev_client)
 
 static uint64_t red_char_device_max_send_tokens(RedCharDevice *dev)
 {
-    GList *item;
+    RedCharDeviceClient *dev_client;
     uint64_t max = 0;
 
-    for (item = dev->priv->clients; item != NULL; item = item->next) {
-        RedCharDeviceClient *dev_client = item->data;
-
+    GLIST_FOREACH(dev->priv->clients, RedCharDeviceClient, dev_client) {
         if (!dev_client->do_flow_control) {
             max = ~0;
             break;
@@ -294,13 +290,9 @@ static void red_char_device_add_msg_to_client_queue(RedCharDeviceClient *dev_cli
 static void red_char_device_send_msg_to_clients(RedCharDevice *dev,
                                                 RedPipeItem *msg)
 {
-    GList *l;
-
-    l = dev->priv->clients;
-    while (l) {
-        GList *next = l->next;
-        RedCharDeviceClient *dev_client = l->data;
+    RedCharDeviceClient *dev_client;
 
+    GLIST_FOREACH(dev->priv->clients, RedCharDeviceClient, dev_client) {
         if (red_char_device_can_send_to_client(dev_client)) {
             dev_client->num_send_tokens--;
             spice_assert(g_queue_is_empty(dev_client->send_queue));
@@ -310,7 +302,6 @@ static void red_char_device_send_msg_to_clients(RedCharDevice *dev,
         } else {
             red_char_device_add_msg_to_client_queue(dev_client, msg);
         }
-        l = next;
     }
 }
 
@@ -823,7 +814,7 @@ void red_char_device_stop(RedCharDevice *dev)
 
 void red_char_device_reset(RedCharDevice *dev)
 {
-    GList *client_item;
+    RedCharDeviceClient *dev_client;
     RedCharDeviceWriteBuffer *buf;
 
     dev->priv->wait_for_migrate_data = FALSE;
@@ -833,9 +824,7 @@ void red_char_device_reset(RedCharDevice *dev)
     }
     red_char_device_write_buffer_release(dev, &dev->priv->cur_write_buf);
 
-    for (client_item = dev->priv->clients; client_item != NULL; client_item = client_item->next) {
-        RedCharDeviceClient *dev_client = client_item->data;
-
+    GLIST_FOREACH(dev->priv->clients, RedCharDeviceClient, dev_client) {
         spice_debug("send_queue_empty %d", g_queue_is_empty(dev_client->send_queue));
         dev_client->num_send_tokens += g_queue_get_length(dev_client->send_queue);
         g_queue_free_full(dev_client->send_queue, (GDestroyNotify)red_pipe_item_unref);
commit e62479574741849d8f0b68d4b05bc47ce3a5fbd4
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Mon Jun 3 08:38:32 2019 +0100

    common-graphics-channel: Avoid closing server if client send huge messages
    
    The Cursor/DisplayChannel is not expecting large messages (which are
    protocol violations).
    
    This fixes https://gitlab.freedesktop.org/spice/spice-server/issues/11.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/server/common-graphics-channel.c b/server/common-graphics-channel.c
index 92349ce4..cea805d0 100644
--- a/server/common-graphics-channel.c
+++ b/server/common-graphics-channel.c
@@ -53,7 +53,7 @@ static uint8_t *common_alloc_recv_buf(RedChannelClient *rcc, uint16_t type, uint
     }
 
     if (size > CHANNEL_RECEIVE_BUF_SIZE) {
-        spice_critical("unexpected message size %u (max is %d)", size, CHANNEL_RECEIVE_BUF_SIZE);
+        spice_warning("unexpected message size %u (max is %d)", size, CHANNEL_RECEIVE_BUF_SIZE);
         return NULL;
     }
     return common->priv->recv_buf;


More information about the Spice-commits mailing list