[Spice-commits] 8 commits - server/inputs-channel.c server/main-channel.c server/reds.c server/tests

Frediano Ziglio fziglio at kemper.freedesktop.org
Tue Dec 5 10:55:07 UTC 2017


 server/inputs-channel.c     |    2 --
 server/main-channel.c       |   18 +++++-------------
 server/reds.c               |   13 ++++++++++---
 server/tests/test-vdagent.c |    5 -----
 4 files changed, 15 insertions(+), 23 deletions(-)

New commits:
commit 7569ff3cc81df6abb41934295a5739c36c76306b
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Sat Dec 2 17:43:54 2017 +0000

    test-vdagent: Remove useless MIN definition
    
    Already defined by GLib headers.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Maybe this check should just be removed?

diff --git a/server/tests/test-vdagent.c b/server/tests/test-vdagent.c
index 01308d0d..c734ddec 100644
--- a/server/tests/test-vdagent.c
+++ b/server/tests/test-vdagent.c
@@ -29,11 +29,6 @@
 #include "test-display-base.h"
 #include "test-glib-compat.h"
 
-#ifndef MIN
-#define MIN(a, b) ((a) > (b) ? (b) : (a))
-#endif
-
-
 static int vmc_write(SPICE_GNUC_UNUSED SpiceCharDeviceInstance *sin,
                      SPICE_GNUC_UNUSED const uint8_t *buf,
                      int len)
commit 60d8389bcd2fd9eab015d92c2905c970339ac164
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Sat Dec 2 16:01:24 2017 +0000

    Handle SPICE_MSGC_DISCONNECTING message in RedChannelClient
    
    There's no reason to handle this message in a different
    way in MainChannel and InputsChannel, the default handling
    will return true in any case.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Maybe this check should just be removed?

diff --git a/server/inputs-channel.c b/server/inputs-channel.c
index 15256ba4..51e25969 100644
--- a/server/inputs-channel.c
+++ b/server/inputs-channel.c
@@ -404,8 +404,6 @@ static bool inputs_channel_handle_message(RedChannelClient *rcc, uint16_t type,
         activate_modifiers_watch(inputs_channel);
         break;
     }
-    case SPICE_MSGC_DISCONNECTING:
-        break;
     default:
         return red_channel_client_handle_message(rcc, type, size, message);
     }
diff --git a/server/main-channel.c b/server/main-channel.c
index 68386b61..23da323f 100644
--- a/server/main-channel.c
+++ b/server/main-channel.c
@@ -216,8 +216,6 @@ static bool main_channel_handle_message(RedChannelClient *rcc, uint16_t type,
     case SPICE_MSGC_PONG:
         main_channel_client_handle_pong(mcc, (SpiceMsgPing *)message, size);
         break;
-    case SPICE_MSGC_DISCONNECTING:
-        break;
     default:
         return red_channel_client_handle_message(rcc, type, size, message);
     }
commit 89c5d062d6c496e5ff669646eb7b85e5343dce1d
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Sat Dec 2 15:59:48 2017 +0000

    reds: Fix wrong assert
    
    RedVDIReadBuf::data is a static allocated buffer so checking for
    NULL on it is useless. It would be NULL only if RedVDIReadBuf
    pointer would be the opposite, in value, of the offset of
    data field into it.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/server/reds.c b/server/reds.c
index 40c82ccc..4ed121a1 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -1242,7 +1242,7 @@ void reds_on_main_channel_migrate(RedsState *reds, MainChannelClient *mcc)
     if (agent_dev->priv->read_state != VDI_PORT_READ_STATE_READ_DATA) {
         return;
     }
-    spice_assert(agent_dev->priv->current_read_buf->data &&
+    spice_assert(agent_dev->priv->current_read_buf &&
                  agent_dev->priv->receive_pos > agent_dev->priv->current_read_buf->data);
     read_data_len = agent_dev->priv->receive_pos - agent_dev->priv->current_read_buf->data;
 
commit ecd9968e91bd60714c7b7a4a9db2de9b807ca686
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Sat Dec 2 14:54:36 2017 +0000

    main-channel: Put all migration message handling together
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/server/main-channel.c b/server/main-channel.c
index 34f54768..68386b61 100644
--- a/server/main-channel.c
+++ b/server/main-channel.c
@@ -207,6 +207,9 @@ static bool main_channel_handle_message(RedChannelClient *rcc, uint16_t type,
         main_channel_client_handle_migrate_dst_do_seamless(mcc,
             ((SpiceMsgcMainMigrateDstDoSeamless *)message)->src_version);
         break;
+    case SPICE_MSGC_MAIN_MIGRATE_END:
+        main_channel_client_handle_migrate_end(mcc);
+        break;
     case SPICE_MSGC_MAIN_MOUSE_MODE_REQUEST:
         reds_on_main_mouse_mode_request(reds, message, size);
         break;
@@ -215,9 +218,6 @@ static bool main_channel_handle_message(RedChannelClient *rcc, uint16_t type,
         break;
     case SPICE_MSGC_DISCONNECTING:
         break;
-    case SPICE_MSGC_MAIN_MIGRATE_END:
-        main_channel_client_handle_migrate_end(mcc);
-        break;
     default:
         return red_channel_client_handle_message(rcc, type, size, message);
     }
commit 57e20c1a2d626366c38d67547cbd55d30eccccbf
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Sat Dec 2 14:54:09 2017 +0000

    main-channel: Remove brackets if not needed
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/server/main-channel.c b/server/main-channel.c
index f5c079f3..34f54768 100644
--- a/server/main-channel.c
+++ b/server/main-channel.c
@@ -177,10 +177,9 @@ static bool main_channel_handle_message(RedChannelClient *rcc, uint16_t type,
         reds_on_main_agent_start(reds, mcc, tokens->num_tokens);
         break;
     }
-    case SPICE_MSGC_MAIN_AGENT_DATA: {
+    case SPICE_MSGC_MAIN_AGENT_DATA:
         reds_on_main_agent_data(reds, mcc, message, size);
         break;
-    }
     case SPICE_MSGC_MAIN_AGENT_TOKEN: {
         SpiceMsgcMainAgentTokens *tokens;
 
@@ -211,10 +210,9 @@ static bool main_channel_handle_message(RedChannelClient *rcc, uint16_t type,
     case SPICE_MSGC_MAIN_MOUSE_MODE_REQUEST:
         reds_on_main_mouse_mode_request(reds, message, size);
         break;
-    case SPICE_MSGC_PONG: {
+    case SPICE_MSGC_PONG:
         main_channel_client_handle_pong(mcc, (SpiceMsgPing *)message, size);
         break;
-    }
     case SPICE_MSGC_DISCONNECTING:
         break;
     case SPICE_MSGC_MAIN_MIGRATE_END:
commit 3fa16234822e6349925a450663f5038c8050499c
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Sat Dec 2 14:53:35 2017 +0000

    main-channel: Remove useless check
    
    If there is a channel client there's surely a related channel.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/server/main-channel.c b/server/main-channel.c
index 43ab39ae..f5c079f3 100644
--- a/server/main-channel.c
+++ b/server/main-channel.c
@@ -165,7 +165,6 @@ static bool main_channel_handle_message(RedChannelClient *rcc, uint16_t type,
                                         uint32_t size, void *message)
 {
     RedChannel *channel = red_channel_client_get_channel(rcc);
-    MainChannel *main_chan = MAIN_CHANNEL(channel);
     MainChannelClient *mcc = MAIN_CHANNEL_CLIENT(rcc);
     RedsState *reds = red_channel_get_server(channel);
 
@@ -174,9 +173,6 @@ static bool main_channel_handle_message(RedChannelClient *rcc, uint16_t type,
         SpiceMsgcMainAgentStart *tokens;
 
         spice_printerr("agent start");
-        if (!main_chan) {
-            return FALSE;
-        }
         tokens = (SpiceMsgcMainAgentStart *)message;
         reds_on_main_agent_start(reds, mcc, tokens->num_tokens);
         break;
commit fc8e55b77bf4a8f34d9c7832862dd6e92db8ea21
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Sat Dec 2 14:00:56 2017 +0000

    reds: Remove leak of agent_dev
    
    This object was not freed.
    Also free object buffers.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/server/reds.c b/server/reds.c
index 4e652253..40c82ccc 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3754,6 +3754,7 @@ SPICE_GNUC_VISIBLE void spice_server_destroy(SpiceServer *reds)
        reds_core_watch_remove(reds, reds->secure_listen_watch);
        close(reds->secure_listen_socket);
     }
+    g_clear_object(&reds->agent_dev);
     spice_buffer_free(&reds->client_monitors_config);
     red_record_unref(reds->record);
     reds_cleanup(reds);
@@ -4535,8 +4536,14 @@ red_char_device_vdi_port_finalize(GObject *object)
 {
     RedCharDeviceVDIPort *dev = RED_CHAR_DEVICE_VDIPORT(object);
 
+    /* make sure we have no other references to RedVDIReadBuf buffers */
+    red_char_device_reset(RED_CHAR_DEVICE(dev));
+    if (dev->priv->current_read_buf) {
+        red_pipe_item_unref(&dev->priv->current_read_buf->base);
+        dev->priv->current_read_buf = NULL;
+    }
+    g_list_free_full(dev->priv->read_bufs, g_free);
     g_free(dev->priv->mig_data);
-   /* FIXME: need to free the RedVDIReadBuf allocated previously */
 
     G_OBJECT_CLASS(red_char_device_vdi_port_parent_class)->finalize(object);
 }
commit 967876d27d2c264493cfeddd794350b31b80f015
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Wed Sep 20 08:02:23 2017 +0100

    reds: Use GLib memory functions for RedVDIReadBuf
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/server/reds.c b/server/reds.c
index 64b3a967..4e652253 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -4519,7 +4519,7 @@ red_char_device_vdi_port_init(RedCharDeviceVDIPort *self)
     self->priv->receive_len = sizeof(self->priv->vdi_chunk_header);
 
     for (i = 0; i < REDS_VDI_PORT_NUM_RECEIVE_BUFFS; i++) {
-        RedVDIReadBuf *buf = spice_new0(RedVDIReadBuf, 1);
+        RedVDIReadBuf *buf = g_new0(RedVDIReadBuf, 1);
         vdi_read_buf_init(buf);
         buf->dev = self;
         g_warn_if_fail(!self->priv->agent_attached);


More information about the Spice-commits mailing list