[Spice-commits] 5 commits - server/cursor-channel.c server/cursor-channel-client.c server/cursor-channel-client.h server/cursor-channel.h server/dcc.c server/display-channel.c server/inputs-channel.c server/inputs-channel-client.c server/inputs-channel.h server/main-channel.c server/main-channel-client.c server/red-channel.c server/red-channel-client.c server/red-channel-client.h server/red-channel.h server/red-worker.c server/smartcard.c server/smartcard-channel-client.c server/smartcard-channel-client.h server/sound.c server/spicevmc.c

Christophe Fergau teuf at kemper.freedesktop.org
Thu Aug 31 13:52:08 UTC 2017


 server/cursor-channel-client.c    |    8 +++++++-
 server/cursor-channel-client.h    |    1 -
 server/cursor-channel.c           |   12 ------------
 server/cursor-channel.h           |    4 ----
 server/dcc.c                      |   22 ++++++++++++++++++++++
 server/display-channel.c          |   21 ---------------------
 server/inputs-channel-client.c    |    9 +++++++++
 server/inputs-channel.c           |   11 +----------
 server/inputs-channel.h           |    1 +
 server/main-channel-client.c      |   12 ++++++++++++
 server/main-channel.c             |   12 ------------
 server/red-channel-client.c       |   11 ++++++++++-
 server/red-channel-client.h       |    2 ++
 server/red-channel.c              |    8 --------
 server/red-channel.h              |    3 ---
 server/red-worker.c               |   33 +++++++++------------------------
 server/smartcard-channel-client.c |    4 +++-
 server/smartcard-channel-client.h |    2 --
 server/smartcard.c                |    1 -
 server/sound.c                    |    7 -------
 server/spicevmc.c                 |    2 +-
 21 files changed, 77 insertions(+), 109 deletions(-)

New commits:
commit b89bd9ef9a25de29f3ec11126b589d475e46377e
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Thu Aug 31 15:44:05 2017 +0200

    worker: Fix 'immediatly' typo in comment
    
    Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/server/red-worker.c b/server/red-worker.c
index 5f49db0d..6ebe6b94 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -357,7 +357,7 @@ static void flush_cursor_commands(RedWorker *worker)
                    red_process_cursor);
 }
 
-// TODO: on timeout, don't disconnect all channels immediatly - try to disconnect the slowest ones
+// TODO: on timeout, don't disconnect all channels immediately - try to disconnect the slowest ones
 // first and maybe turn timeouts to several timeouts in order to disconnect channels gradually.
 // Should use disconnect or shutdown?
 static void flush_all_qxl_commands(RedWorker *worker)
commit ab1348486d44be40a905f90b19b96e341382eb7f
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Wed Aug 30 10:35:54 2017 +0200

    worker: Simplify flush_commands()
    
    red_disconnect_display() is duplicating what red_channel_disconnect()
    already does, so red_disconnect_display() and red_disconnect_cursor()
    are actually identical code-wise. We can directly call
    red_channel_disconnect() from flush_commands() rather than passing a
    'red_disconnect_t disconnect' argument to that function.
    
    Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/red-worker.c b/server/red-worker.c
index 109db63e..5f49db0d 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -284,17 +284,6 @@ static bool red_process_is_blocked(RedWorker *worker)
            red_channel_max_pipe_size(RED_CHANNEL(worker->display_channel)) > MAX_PIPE_SIZE;
 }
 
-static void red_disconnect_display(RedWorker *worker)
-{
-    spice_warning("update timeout");
-
-    // TODO: we need to record the client that actually causes the timeout. So
-    // we need to check the locations of the various pipe heads when counting,
-    // and disconnect only those/that.
-    red_channel_apply_clients(RED_CHANNEL(worker->display_channel),
-                              red_channel_client_disconnect);
-}
-
 static void red_migrate_display(DisplayChannel *display, RedChannelClient *rcc)
 {
     /* We need to stop the streams, and to send upgrade_items to the client.
@@ -314,10 +303,8 @@ static void red_migrate_display(DisplayChannel *display, RedChannelClient *rcc)
 }
 
 typedef int (*red_process_t)(RedWorker *worker, int *ring_is_empty);
-typedef void (*red_disconnect_t)(RedWorker *worker);
-
 static void flush_commands(RedWorker *worker, RedChannel *red_channel,
-                           red_process_t process, red_disconnect_t disconnect)
+                           red_process_t process)
 {
     for (;;) {
         uint64_t end_time;
@@ -346,7 +333,11 @@ static void flush_commands(RedWorker *worker, RedChannel *red_channel,
             // TODO: MC: the whole timeout will break since it takes lowest timeout, should
             // do it client by client.
             if (spice_get_monotonic_time_ns() >= end_time) {
-                disconnect(worker);
+                // TODO: we need to record the client that actually causes the timeout.
+                // So we need to check the locations of the various pipe heads when counting,
+                // and disconnect only those/that.
+                spice_warning("flush timeout");
+                red_channel_disconnect(red_channel);
             } else {
                 usleep(DISPLAY_CLIENT_RETRY_INTERVAL);
             }
@@ -357,19 +348,13 @@ static void flush_commands(RedWorker *worker, RedChannel *red_channel,
 static void flush_display_commands(RedWorker *worker)
 {
     flush_commands(worker, RED_CHANNEL(worker->display_channel),
-                   red_process_display, red_disconnect_display);
-}
-
-static void red_disconnect_cursor(RedWorker *worker)
-{
-    spice_warning("flush cursor timeout");
-    red_channel_disconnect(RED_CHANNEL(worker->cursor_channel));
+                   red_process_display);
 }
 
 static void flush_cursor_commands(RedWorker *worker)
 {
     flush_commands(worker, RED_CHANNEL(worker->cursor_channel),
-                   red_process_cursor, red_disconnect_cursor);
+                   red_process_cursor);
 }
 
 // TODO: on timeout, don't disconnect all channels immediatly - try to disconnect the slowest ones
commit becd0d30f6d87a8bde3efc8e6645a9b5db383606
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Wed Aug 30 10:28:45 2017 +0200

    cursor: Remove cursor_channel_disconnect()
    
    cursor_channel_disconnect() calls
    cursor_channel_client_reset_cursor_cache() on all CursorChannelClient
    associated with the current CursorChannel before calling
    red_channel_disconnect().
    
    red_channel_disconnect() will iterate over all CursorChannelClient
    calling red_channel_client_disconnect(), which will eventually call
    CursorChannelClient::on_disconnect. This will in turn
    cursor_channel_client_reset_cursor_cache(), so calling it in
    cursor_channel_disconnect() before calling red_channel_disconnect() is
    redundant.
    
    cursor_channel_disconnect() can thus be replaced by a direct call to
    red_channel_disconnect().
    
    Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/cursor-channel.c b/server/cursor-channel.c
index f35c9b20..8ac5af47 100644
--- a/server/cursor-channel.c
+++ b/server/cursor-channel.c
@@ -158,17 +158,6 @@ static void cursor_fill(CursorChannelClient *ccc, CursorItem *cursor,
     }
 }
 
-void cursor_channel_disconnect(CursorChannel *cursor_channel)
-{
-    RedChannel *channel = RED_CHANNEL(cursor_channel);
-
-    if (!channel || !red_channel_is_connected(channel)) {
-        return;
-    }
-    red_channel_apply_clients(channel, cursor_channel_client_reset_cursor_cache);
-    red_channel_disconnect(channel);
-}
-
 static void cursor_pipe_item_free(RedPipeItem *base)
 {
     spice_return_if_fail(base);
diff --git a/server/cursor-channel.h b/server/cursor-channel.h
index 9f3ef52e..f279aafc 100644
--- a/server/cursor-channel.h
+++ b/server/cursor-channel.h
@@ -59,10 +59,6 @@ GType cursor_channel_get_type(void) G_GNUC_CONST;
 CursorChannel*       cursor_channel_new         (RedsState *server, QXLInstance *qxl,
                                                  const SpiceCoreInterfaceInternal *core);
 
-/**
- * Cause the channel to disconnect all clients
- */
-void                 cursor_channel_disconnect  (CursorChannel *cursor);
 void                 cursor_channel_reset       (CursorChannel *cursor);
 void                 cursor_channel_do_init     (CursorChannel *cursor);
 void                 cursor_channel_process_cmd (CursorChannel *cursor, RedCursorCmd *cursor_cmd);
diff --git a/server/red-worker.c b/server/red-worker.c
index 0e2e8fa3..109db63e 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -363,7 +363,7 @@ static void flush_display_commands(RedWorker *worker)
 static void red_disconnect_cursor(RedWorker *worker)
 {
     spice_warning("flush cursor timeout");
-    cursor_channel_disconnect(worker->cursor_channel);
+    red_channel_disconnect(RED_CHANNEL(worker->cursor_channel));
 }
 
 static void flush_cursor_commands(RedWorker *worker)
commit 54eb7716f0e9f1ca1ae36e17e2b3cc6e711e4a6e
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Wed Aug 30 10:20:08 2017 +0200

    channel: Allow NULL RedChannelClient::on_disconnect()
    
    SoundChannelClient has a stub implementation of
    RedChannelClient::on_disconnect(), this commit removes the need for it.
    
    Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 43b8eb8b..2612a6db 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -1669,7 +1669,9 @@ static void red_channel_client_on_disconnect(RedChannelClient *rcc)
 {
     RedChannelClientClass *klass = RED_CHANNEL_CLIENT_GET_CLASS(rcc);
 
-    klass->on_disconnect(rcc);
+    if (klass->on_disconnect != NULL) {
+        klass->on_disconnect(rcc);
+    }
 }
 
 void red_channel_client_disconnect(RedChannelClient *rcc)
diff --git a/server/sound.c b/server/sound.c
index 28e18126..de51a467 100644
--- a/server/sound.c
+++ b/server/sound.c
@@ -789,10 +789,6 @@ static bool snd_channel_client_config_socket(RedChannelClient *rcc)
     return true;
 }
 
-static void snd_channel_client_on_disconnect(RedChannelClient *rcc)
-{
-}
-
 static uint8_t*
 snd_channel_client_alloc_recv_buf(RedChannelClient *rcc, uint16_t type, uint32_t size)
 {
@@ -1475,7 +1471,6 @@ snd_channel_client_class_init(SndChannelClientClass *klass)
     client_class->config_socket = snd_channel_client_config_socket;
     client_class->alloc_recv_buf = snd_channel_client_alloc_recv_buf;
     client_class->release_recv_buf = snd_channel_client_release_recv_buf;
-    client_class->on_disconnect = snd_channel_client_on_disconnect;
 }
 
 static void
commit 5dbfbb4d78803de9bd7166a2cbb7efe8fe86f393
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Wed Aug 30 10:18:25 2017 +0200

    channel: Move RedChannel::on_disconnect to RedChannelClient
    
    This vfunc only has a RedChannelClient * argument, and most of the time,
    it operates on RedChannelClient, not on RedChannel. Moreover, the only
    time it's used is from RedChannelClient. This commit moves the vfunc to
    RedChannelClient, which seems like a better fit for it.
    
    Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/cursor-channel-client.c b/server/cursor-channel-client.c
index bbb0588f..42ab5d76 100644
--- a/server/cursor-channel-client.c
+++ b/server/cursor-channel-client.c
@@ -48,10 +48,16 @@ struct CursorChannelClientPrivate
     uint32_t cursor_cache_items;
 };
 
+static void cursor_channel_client_on_disconnect(RedChannelClient *rcc);
+
 static void
 cursor_channel_client_class_init(CursorChannelClientClass *klass)
 {
+    RedChannelClientClass *client_class = RED_CHANNEL_CLIENT_CLASS(klass);
+
     g_type_class_add_private(klass, sizeof(CursorChannelClientPrivate));
+
+    client_class->on_disconnect = cursor_channel_client_on_disconnect;
 }
 
 static void
@@ -75,7 +81,7 @@ void cursor_channel_client_reset_cursor_cache(RedChannelClient *rcc)
     red_cursor_cache_reset(CURSOR_CHANNEL_CLIENT(rcc), CLIENT_CURSOR_CACHE_SIZE);
 }
 
-void cursor_channel_client_on_disconnect(RedChannelClient *rcc)
+static void cursor_channel_client_on_disconnect(RedChannelClient *rcc)
 {
     if (!rcc) {
         return;
diff --git a/server/cursor-channel-client.h b/server/cursor-channel-client.h
index 82612659..dc69369f 100644
--- a/server/cursor-channel-client.h
+++ b/server/cursor-channel-client.h
@@ -66,7 +66,6 @@ CursorChannelClient* cursor_channel_client_new(CursorChannel *cursor,
                                                RedChannelCapabilities *caps);
 
 void cursor_channel_client_reset_cursor_cache(RedChannelClient *rcc);
-void cursor_channel_client_on_disconnect(RedChannelClient *rcc);
 RedCacheItem* cursor_channel_client_cache_find(CursorChannelClient *ccc, uint64_t id);
 int cursor_channel_client_cache_add(CursorChannelClient *ccc, uint64_t id, size_t size);
 
diff --git a/server/cursor-channel.c b/server/cursor-channel.c
index 5ece576c..f35c9b20 100644
--- a/server/cursor-channel.c
+++ b/server/cursor-channel.c
@@ -448,7 +448,6 @@ cursor_channel_class_init(CursorChannelClass *klass)
     channel_class->parser = spice_get_client_channel_parser(SPICE_CHANNEL_CURSOR, NULL);
     channel_class->handle_message = red_channel_client_handle_message;
 
-    channel_class->on_disconnect =  cursor_channel_client_on_disconnect;
     channel_class->send_item = cursor_channel_send_item;
 }
 
diff --git a/server/dcc.c b/server/dcc.c
index 2778bb88..ec8b6074 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -42,6 +42,7 @@ enum
 
 static void on_display_video_codecs_update(GObject *gobject, GParamSpec *pspec, gpointer user_data);
 static bool dcc_config_socket(RedChannelClient *rcc);
+static void dcc_on_disconnect(RedChannelClient *rcc);
 
 static void
 display_channel_client_get_property(GObject *object,
@@ -133,6 +134,7 @@ display_channel_client_class_init(DisplayChannelClientClass *klass)
     object_class->finalize = display_channel_client_finalize;
 
     client_class->config_socket = dcc_config_socket;
+    client_class->on_disconnect = dcc_on_disconnect;
 
     g_object_class_install_property(object_class,
                                     PROP_IMAGE_COMPRESSION,
@@ -1429,6 +1431,26 @@ static bool dcc_config_socket(RedChannelClient *rcc)
     return common_channel_client_config_socket(rcc);
 }
 
+static void dcc_on_disconnect(RedChannelClient *rcc)
+{
+    DisplayChannel *display;
+    DisplayChannelClient *dcc;
+
+    spice_debug("trace");
+    spice_return_if_fail(rcc != NULL);
+
+    dcc = DISPLAY_CHANNEL_CLIENT(rcc);
+    display = DCC_TO_DC(dcc);
+
+    dcc_stop(dcc); // TODO: start/stop -> connect/disconnect?
+    display_channel_compress_stats_print(display);
+
+    // this was the last channel client
+    spice_debug("#draw=%d, #glz_draw=%d",
+                display->priv->drawable_count,
+                display->priv->encoder_shared_data.glz_drawable_count);
+}
+
 gboolean dcc_is_low_bandwidth(DisplayChannelClient *dcc)
 {
     return dcc->is_low_bandwidth;
diff --git a/server/display-channel.c b/server/display-channel.c
index 792fbd25..c745790f 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -2189,26 +2189,6 @@ void display_channel_create_surface(DisplayChannel *display, uint32_t surface_id
         send_create_surface(display, surface_id, data_is_valid);
 }
 
-static void on_disconnect(RedChannelClient *rcc)
-{
-    DisplayChannel *display;
-    DisplayChannelClient *dcc;
-
-    spice_debug("trace");
-    spice_return_if_fail(rcc != NULL);
-
-    dcc = DISPLAY_CHANNEL_CLIENT(rcc);
-    display = DCC_TO_DC(dcc);
-
-    dcc_stop(dcc); // TODO: start/stop -> connect/disconnect?
-    display_channel_compress_stats_print(display);
-
-    // this was the last channel client
-    spice_debug("#draw=%d, #glz_draw=%d",
-                display->priv->drawable_count,
-                display->priv->encoder_shared_data.glz_drawable_count);
-}
-
 static bool handle_migrate_flush_mark(RedChannelClient *rcc)
 {
     RedChannel *channel = red_channel_client_get_channel(rcc);
@@ -2510,7 +2490,6 @@ display_channel_class_init(DisplayChannelClass *klass)
     channel_class->parser = spice_get_client_channel_parser(SPICE_CHANNEL_DISPLAY, NULL);
     channel_class->handle_message = dcc_handle_message;
 
-    channel_class->on_disconnect = on_disconnect;
     channel_class->send_item = dcc_send_item;
     channel_class->handle_migrate_flush_mark = handle_migrate_flush_mark;
     channel_class->handle_migrate_data = handle_migrate_data;
diff --git a/server/inputs-channel-client.c b/server/inputs-channel-client.c
index c28e24eb..c9c88da2 100644
--- a/server/inputs-channel-client.c
+++ b/server/inputs-channel-client.c
@@ -63,6 +63,14 @@ inputs_channel_client_release_msg_rcv_buf(RedChannelClient *rcc,
 {
 }
 
+static void inputs_channel_client_on_disconnect(RedChannelClient *rcc)
+{
+    if (!rcc) {
+        return;
+    }
+    inputs_release_keys(INPUTS_CHANNEL(red_channel_client_get_channel(rcc)));
+}
+
 static void
 inputs_channel_client_class_init(InputsChannelClientClass *klass)
 {
@@ -72,6 +80,7 @@ inputs_channel_client_class_init(InputsChannelClientClass *klass)
 
     client_class->alloc_recv_buf = inputs_channel_client_alloc_msg_rcv_buf;
     client_class->release_recv_buf = inputs_channel_client_release_msg_rcv_buf;
+    client_class->on_disconnect = inputs_channel_client_on_disconnect;
 }
 
 static void
diff --git a/server/inputs-channel.c b/server/inputs-channel.c
index 943c69d6..5ddf2b39 100644
--- a/server/inputs-channel.c
+++ b/server/inputs-channel.c
@@ -405,7 +405,7 @@ static bool inputs_channel_handle_message(RedChannelClient *rcc, uint16_t type,
     return TRUE;
 }
 
-static void inputs_release_keys(InputsChannel *inputs)
+void inputs_release_keys(InputsChannel *inputs)
 {
     int i;
     SpiceKbdState *st;
@@ -434,14 +434,6 @@ static void inputs_release_keys(InputsChannel *inputs)
     }
 }
 
-static void inputs_channel_on_disconnect(RedChannelClient *rcc)
-{
-    if (!rcc) {
-        return;
-    }
-    inputs_release_keys(INPUTS_CHANNEL(red_channel_client_get_channel(rcc)));
-}
-
 static void inputs_pipe_add_init(RedChannelClient *rcc)
 {
     RedInputsInitPipeItem *item = spice_malloc(sizeof(RedInputsInitPipeItem));
@@ -594,7 +586,6 @@ inputs_channel_class_init(InputsChannelClass *klass)
     channel_class->handle_message = inputs_channel_handle_message;
 
     /* channel callbacks */
-    channel_class->on_disconnect = inputs_channel_on_disconnect;
     channel_class->send_item = inputs_channel_send_item;
     channel_class->handle_migrate_data = inputs_channel_handle_migrate_data;
     channel_class->handle_migrate_flush_mark = inputs_channel_handle_migrate_flush_mark;
diff --git a/server/inputs-channel.h b/server/inputs-channel.h
index e3cc2519..27d81a87 100644
--- a/server/inputs-channel.h
+++ b/server/inputs-channel.h
@@ -58,6 +58,7 @@ void inputs_channel_detach_tablet(InputsChannel *inputs, SpiceTabletInstance *ta
 RedsState* spice_tablet_state_get_server(SpiceTabletState *dev);
 RedsState* spice_kbd_state_get_server(SpiceKbdState *dev);
 gboolean inputs_channel_is_src_during_migrate(InputsChannel *inputs);
+void inputs_release_keys(InputsChannel *inputs);
 
 G_END_DECLS
 
diff --git a/server/main-channel-client.c b/server/main-channel-client.c
index db8e4823..4d841c81 100644
--- a/server/main-channel-client.c
+++ b/server/main-channel-client.c
@@ -189,6 +189,17 @@ main_channel_client_release_msg_rcv_buf(RedChannelClient *rcc,
     }
 }
 
+/*
+ * When the main channel is disconnected, disconnect the entire client.
+ */
+static void main_channel_client_on_disconnect(RedChannelClient *rcc)
+{
+    RedsState *reds = red_channel_get_server(red_channel_client_get_channel(rcc));
+    spice_printerr("rcc=%p", rcc);
+    main_dispatcher_client_disconnect(reds_get_main_dispatcher(reds),
+                                      red_channel_client_get_client(rcc));
+}
+
 static void main_channel_client_class_init(MainChannelClientClass *klass)
 {
     GObjectClass *object_class = G_OBJECT_CLASS(klass);
@@ -201,6 +212,7 @@ static void main_channel_client_class_init(MainChannelClientClass *klass)
 
     client_class->alloc_recv_buf = main_channel_client_alloc_msg_rcv_buf;
     client_class->release_recv_buf = main_channel_client_release_msg_rcv_buf;
+    client_class->on_disconnect = main_channel_client_on_disconnect;
 
     g_object_class_install_property(object_class,
                                     PROP_CONNECTION_ID,
diff --git a/server/main-channel.c b/server/main-channel.c
index 982b6203..c30374c3 100644
--- a/server/main-channel.c
+++ b/server/main-channel.c
@@ -49,17 +49,6 @@ int main_channel_is_connected(MainChannel *main_chan)
     return red_channel_is_connected(RED_CHANNEL(main_chan));
 }
 
-/*
- * When the main channel is disconnected, disconnect the entire client.
- */
-static void main_channel_client_on_disconnect(RedChannelClient *rcc)
-{
-    RedsState *reds = red_channel_get_server(red_channel_client_get_channel(rcc));
-    spice_printerr("rcc=%p", rcc);
-    main_dispatcher_client_disconnect(reds_get_main_dispatcher(reds),
-                                      red_channel_client_get_client(rcc));
-}
-
 RedClient *main_channel_get_client_by_link_id(MainChannel *main_chan, uint32_t connection_id)
 {
     RedChannelClient *rcc;
@@ -315,7 +304,6 @@ main_channel_class_init(MainChannelClass *klass)
     channel_class->handle_message = main_channel_handle_message;
 
     /* channel callbacks */
-    channel_class->on_disconnect = main_channel_client_on_disconnect;
     channel_class->send_item = main_channel_client_send_item;
     channel_class->handle_migrate_flush_mark = main_channel_handle_migrate_flush_mark;
     channel_class->handle_migrate_data = main_channel_handle_migrate_data;
diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 145ba43f..43b8eb8b 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -1665,6 +1665,13 @@ void red_channel_client_push_set_ack(RedChannelClient *rcc)
     red_channel_client_pipe_add_type(rcc, RED_PIPE_ITEM_TYPE_SET_ACK);
 }
 
+static void red_channel_client_on_disconnect(RedChannelClient *rcc)
+{
+    RedChannelClientClass *klass = RED_CHANNEL_CLIENT_GET_CLASS(rcc);
+
+    klass->on_disconnect(rcc);
+}
+
 void red_channel_client_disconnect(RedChannelClient *rcc)
 {
     RedChannel *channel = rcc->priv->channel;
@@ -1691,7 +1698,7 @@ void red_channel_client_disconnect(RedChannelClient *rcc)
         rcc->priv->connectivity_monitor.timer = NULL;
     }
     red_channel_remove_client(channel, rcc);
-    red_channel_on_disconnect(channel, rcc);
+    red_channel_client_on_disconnect(rcc);
 }
 
 gboolean red_channel_client_is_blocked(RedChannelClient *rcc)
diff --git a/server/red-channel-client.h b/server/red-channel-client.h
index 057732f4..3665dacc 100644
--- a/server/red-channel-client.h
+++ b/server/red-channel-client.h
@@ -168,6 +168,8 @@ struct RedChannelClientClass
     bool (*config_socket)(RedChannelClient *rcc);
     uint8_t *(*alloc_recv_buf)(RedChannelClient *channel, uint16_t type, uint32_t size);
     void (*release_recv_buf)(RedChannelClient *channel, uint16_t type, uint32_t size, uint8_t *msg);
+
+    void (*on_disconnect)(RedChannelClient *rcc);
 };
 
 #define SPICE_SERVER_ERROR spice_server_error_quark()
diff --git a/server/red-channel.c b/server/red-channel.c
index 9ff3474a..a8ab5230 100644
--- a/server/red-channel.c
+++ b/server/red-channel.c
@@ -198,7 +198,6 @@ red_channel_constructed(GObject *object)
 
     G_OBJECT_CLASS(red_channel_parent_class)->constructed(object);
 
-    spice_assert(klass->on_disconnect);
     spice_assert(klass->handle_migrate_data ||
                  !(self->priv->migration_flags & SPICE_MIGRATE_NEED_DATA_TRANSFER));
 }
@@ -692,13 +691,6 @@ SpiceCoreInterfaceInternal* red_channel_get_core_interface(RedChannel *channel)
     return channel->priv->core;
 }
 
-void red_channel_on_disconnect(RedChannel *self, RedChannelClient *rcc)
-{
-    RedChannelClass *klass = RED_CHANNEL_GET_CLASS(self);
-
-    klass->on_disconnect(rcc);
-}
-
 void red_channel_send_item(RedChannel *self, RedChannelClient *rcc, RedPipeItem *item)
 {
     RedChannelClass *klass = RED_CHANNEL_GET_CLASS(self);
diff --git a/server/red-channel.h b/server/red-channel.h
index e65eea1e..8ea5a711 100644
--- a/server/red-channel.h
+++ b/server/red-channel.h
@@ -45,7 +45,6 @@ typedef struct MainChannelClient MainChannelClient;
 
 typedef bool (*channel_handle_message_proc)(RedChannelClient *rcc, uint16_t type,
                                             uint32_t size, void *msg);
-typedef void (*channel_disconnect_proc)(RedChannelClient *rcc);
 typedef bool (*channel_configure_socket_proc)(RedChannelClient *rcc);
 typedef void (*channel_send_pipe_item_proc)(RedChannelClient *rcc, RedPipeItem *item);
 
@@ -115,7 +114,6 @@ struct RedChannelClass
      * callbacks that are triggered from channel client stream events.
      * They are called from the thread that listen to the stream events.
      */
-    channel_disconnect_proc on_disconnect;
     channel_send_pipe_item_proc send_item;
     channel_handle_migrate_flush_mark_proc handle_migrate_flush_mark;
     channel_handle_migrate_data_proc handle_migrate_data;
@@ -217,7 +215,6 @@ struct RedsState* red_channel_get_server(RedChannel *channel);
 SpiceCoreInterfaceInternal* red_channel_get_core_interface(RedChannel *channel);
 
 /* channel callback function */
-void red_channel_on_disconnect(RedChannel *self, RedChannelClient *rcc);
 void red_channel_send_item(RedChannel *self, RedChannelClient *rcc, RedPipeItem *item);
 void red_channel_reset_thread_id(RedChannel *self);
 const RedStatNode *red_channel_get_stat_node(RedChannel *channel);
diff --git a/server/smartcard-channel-client.c b/server/smartcard-channel-client.c
index e934b2e9..7a2ef0dd 100644
--- a/server/smartcard-channel-client.c
+++ b/server/smartcard-channel-client.c
@@ -48,6 +48,7 @@ smartcard_channel_client_alloc_msg_rcv_buf(RedChannelClient *rcc, uint16_t type,
 static void
 smartcard_channel_client_release_msg_rcv_buf(RedChannelClient *rcc, uint16_t type,
                                              uint32_t size, uint8_t *msg);
+static void smartcard_channel_client_on_disconnect(RedChannelClient *rcc);
 
 static void smart_card_channel_client_get_property(GObject *object,
                                                    guint property_id,
@@ -92,6 +93,7 @@ static void smart_card_channel_client_class_init(SmartCardChannelClientClass *kl
     RedChannelClientClass *client_class = RED_CHANNEL_CLIENT_CLASS(klass);
     client_class->alloc_recv_buf = smartcard_channel_client_alloc_msg_rcv_buf;
     client_class->release_recv_buf = smartcard_channel_client_release_msg_rcv_buf;
+    client_class->on_disconnect = smartcard_channel_client_on_disconnect;
 
     object_class->get_property = smart_card_channel_client_get_property;
     object_class->set_property = smart_card_channel_client_set_property;
@@ -176,7 +178,7 @@ smartcard_channel_client_release_msg_rcv_buf(RedChannelClient *rcc,
     }
 }
 
-void smartcard_channel_client_on_disconnect(RedChannelClient *rcc)
+static void smartcard_channel_client_on_disconnect(RedChannelClient *rcc)
 {
     SmartCardChannelClient *scc = SMARTCARD_CHANNEL_CLIENT(rcc);
     RedCharDeviceSmartcard *device = scc->priv->smartcard;
diff --git a/server/smartcard-channel-client.h b/server/smartcard-channel-client.h
index 8f2ab0f0..fffad231 100644
--- a/server/smartcard-channel-client.h
+++ b/server/smartcard-channel-client.h
@@ -61,8 +61,6 @@ SmartCardChannelClient* smartcard_channel_client_create(RedChannel *channel,
 
 bool smartcard_channel_client_handle_migrate_flush_mark(RedChannelClient *rcc);
 
-void smartcard_channel_client_on_disconnect(RedChannelClient *rcc);
-
 void smartcard_channel_client_send_data(RedChannelClient *rcc,
                                         SpiceMarshaller *m,
                                         RedPipeItem *item,
diff --git a/server/smartcard.c b/server/smartcard.c
index ac2fc1e1..73f24851 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -574,7 +574,6 @@ red_smartcard_channel_class_init(RedSmartcardChannelClass *klass)
 
     channel_class->handle_message = smartcard_channel_client_handle_message,
 
-    channel_class->on_disconnect = smartcard_channel_client_on_disconnect;
     channel_class->send_item = smartcard_channel_send_item;
     channel_class->handle_migrate_flush_mark = smartcard_channel_client_handle_migrate_flush_mark;
     channel_class->handle_migrate_data = smartcard_channel_client_handle_migrate_data;
diff --git a/server/sound.c b/server/sound.c
index 54b89713..28e18126 100644
--- a/server/sound.c
+++ b/server/sound.c
@@ -789,7 +789,7 @@ static bool snd_channel_client_config_socket(RedChannelClient *rcc)
     return true;
 }
 
-static void snd_channel_on_disconnect(RedChannelClient *rcc)
+static void snd_channel_client_on_disconnect(RedChannelClient *rcc)
 {
 }
 
@@ -1316,11 +1316,8 @@ static void
 snd_channel_class_init(SndChannelClass *klass)
 {
     GObjectClass *object_class = G_OBJECT_CLASS(klass);
-    RedChannelClass *channel_class = RED_CHANNEL_CLASS(klass);
 
     object_class->finalize = snd_channel_finalize;
-
-    channel_class->on_disconnect = snd_channel_on_disconnect;
 }
 
 static void
@@ -1478,6 +1475,7 @@ snd_channel_client_class_init(SndChannelClientClass *klass)
     client_class->config_socket = snd_channel_client_config_socket;
     client_class->alloc_recv_buf = snd_channel_client_alloc_recv_buf;
     client_class->release_recv_buf = snd_channel_client_release_recv_buf;
+    client_class->on_disconnect = snd_channel_client_on_disconnect;
 }
 
 static void
diff --git a/server/spicevmc.c b/server/spicevmc.c
index 9305c9b4..51b6913c 100644
--- a/server/spicevmc.c
+++ b/server/spicevmc.c
@@ -763,7 +763,6 @@ red_vmc_channel_class_init(RedVmcChannelClass *klass)
 
     channel_class->handle_message = spicevmc_red_channel_client_handle_message;
 
-    channel_class->on_disconnect = spicevmc_red_channel_client_on_disconnect;
     channel_class->send_item = spicevmc_red_channel_send_item;
     channel_class->handle_migrate_flush_mark = spicevmc_channel_client_handle_migrate_flush_mark;
     channel_class->handle_migrate_data = spicevmc_channel_client_handle_migrate_data;
@@ -986,6 +985,7 @@ vmc_channel_client_class_init(VmcChannelClientClass *klass)
 
     client_class->alloc_recv_buf = spicevmc_red_channel_alloc_msg_rcv_buf;
     client_class->release_recv_buf = spicevmc_red_channel_release_msg_rcv_buf;
+    client_class->on_disconnect = spicevmc_red_channel_client_on_disconnect;
 }
 
 static RedChannelClient *


More information about the Spice-commits mailing list