[Spice-commits] server/inputs-channel.c server/main-channel.c server/red-channel.c server/red-channel.h server/red-worker.c server/smartcard.c server/sound.c server/spicevmc.c

Frediano Ziglio fziglio at kemper.freedesktop.org
Fri Feb 12 15:28:03 UTC 2016


 server/inputs-channel.c |    1 +
 server/main-channel.c   |    3 ++-
 server/red-channel.c    |   24 ++++++++++++++----------
 server/red-channel.h    |   19 +++++++++++--------
 server/red-worker.c     |    2 +-
 server/smartcard.c      |    1 +
 server/sound.c          |    4 ++--
 server/spicevmc.c       |    2 +-
 8 files changed, 33 insertions(+), 23 deletions(-)

New commits:
commit dc4051fb9af59d2d9c7d9983d25e59249c945cb2
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date:   Fri Jan 30 16:53:54 2015 -0600

    Store a reference to RedsState in Channel base class
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/inputs-channel.c b/server/inputs-channel.c
index f47a586..71716d5 100644
--- a/server/inputs-channel.c
+++ b/server/inputs-channel.c
@@ -636,6 +636,7 @@ InputsChannel* inputs_channel_new(void)
 
     inputs = (InputsChannel *)red_channel_create_parser(
                                     sizeof(InputsChannel),
+                                    reds,
                                     reds_get_core_interface(reds),
                                     SPICE_CHANNEL_INPUTS, 0,
                                     FALSE, /* handle_acks */
diff --git a/server/main-channel.c b/server/main-channel.c
index d69095d..e2f7ae3 100644
--- a/server/main-channel.c
+++ b/server/main-channel.c
@@ -1179,7 +1179,8 @@ MainChannel* main_channel_new(void)
     channel_cbs.handle_migrate_data = main_channel_handle_migrate_data;
 
     // TODO: set the migration flag of the channel
-    channel = red_channel_create_parser(sizeof(MainChannel), reds_get_core_interface(reds),
+    channel = red_channel_create_parser(sizeof(MainChannel), reds,
+                                        reds_get_core_interface(reds),
                                         SPICE_CHANNEL_MAIN, 0,
                                         FALSE, /* handle_acks */
                                         spice_get_client_channel_parser(SPICE_CHANNEL_MAIN, NULL),
diff --git a/server/red-channel.c b/server/red-channel.c
index 3cc12f3..d5ca701 100644
--- a/server/red-channel.c
+++ b/server/red-channel.c
@@ -1016,6 +1016,7 @@ void red_channel_client_default_migrate(RedChannelClient *rcc)
 }
 
 RedChannel *red_channel_create(int size,
+                               RedsState *reds,
                                const SpiceCoreInterfaceInternal *core,
                                uint32_t type, uint32_t id,
                                int handle_acks,
@@ -1039,6 +1040,7 @@ RedChannel *red_channel_create(int size,
     channel->migration_flags = migration_flags;
     memcpy(&channel->channel_cbs, channel_cbs, sizeof(ChannelCbs));
 
+    channel->reds = reds;
     channel->core = core;
     ring_init(&channel->clients);
 
@@ -1095,7 +1097,7 @@ SpiceCoreInterfaceInternal dummy_core = {
     .watch_remove = dummy_watch_remove,
 };
 
-RedChannel *red_channel_create_dummy(int size, uint32_t type, uint32_t id)
+RedChannel *red_channel_create_dummy(int size, RedsState *reds, uint32_t type, uint32_t id)
 {
     RedChannel *channel;
     ClientCbs client_cbs = { NULL, };
@@ -1105,6 +1107,7 @@ RedChannel *red_channel_create_dummy(int size, uint32_t type, uint32_t id)
     channel->type = type;
     channel->id = id;
     channel->refs = 1;
+    channel->reds = reds;
     channel->core = &dummy_core;
     ring_init(&channel->clients);
     client_cbs.connect = red_channel_client_default_connect;
@@ -1132,15 +1135,16 @@ static int do_nothing_handle_message(RedChannelClient *rcc,
 }
 
 RedChannel *red_channel_create_parser(int size,
-                               const SpiceCoreInterfaceInternal *core,
-                               uint32_t type, uint32_t id,
-                               int handle_acks,
-                               spice_parse_channel_func_t parser,
-                               channel_handle_parsed_proc handle_parsed,
-                               const ChannelCbs *channel_cbs,
-                               uint32_t migration_flags)
-{
-    RedChannel *channel = red_channel_create(size, core, type, id,
+                                      RedsState *reds,
+                                      const SpiceCoreInterfaceInternal *core,
+                                      uint32_t type, uint32_t id,
+                                      int handle_acks,
+                                      spice_parse_channel_func_t parser,
+                                      channel_handle_parsed_proc handle_parsed,
+                                      const ChannelCbs *channel_cbs,
+                                      uint32_t migration_flags)
+{
+    RedChannel *channel = red_channel_create(size, reds, core, type, id,
                                              handle_acks,
                                              do_nothing_handle_message,
                                              channel_cbs,
diff --git a/server/red-channel.h b/server/red-channel.h
index c49c506..26bd3f9 100644
--- a/server/red-channel.h
+++ b/server/red-channel.h
@@ -337,6 +337,7 @@ struct RedChannel {
 
     // TODO: when different channel_clients are in different threads from Channel -> need to protect!
     pthread_t thread_id;
+    struct RedsState *reds;
 #ifdef RED_STATISTICS
     StatNodeRef stat;
     uint64_t *out_bytes_counter;
@@ -359,6 +360,7 @@ struct RedChannel {
 /* if one of the callbacks should cause disconnect, use red_channel_shutdown and don't
  * explicitly destroy the channel */
 RedChannel *red_channel_create(int size,
+                               struct RedsState *reds,
                                const SpiceCoreInterfaceInternal *core,
                                uint32_t type, uint32_t id,
                                int handle_acks,
@@ -369,13 +371,14 @@ RedChannel *red_channel_create(int size,
 /* alternative constructor, meant for marshaller based (inputs,main) channels,
  * will become default eventually */
 RedChannel *red_channel_create_parser(int size,
-                               const SpiceCoreInterfaceInternal *core,
-                               uint32_t type, uint32_t id,
-                               int handle_acks,
-                               spice_parse_channel_func_t parser,
-                               channel_handle_parsed_proc handle_parsed,
-                               const ChannelCbs *channel_cbs,
-                               uint32_t migration_flags);
+                                      struct RedsState *reds,
+                                      const SpiceCoreInterfaceInternal *core,
+                                      uint32_t type, uint32_t id,
+                                      int handle_acks,
+                                      spice_parse_channel_func_t parser,
+                                      channel_handle_parsed_proc handle_parsed,
+                                      const ChannelCbs *channel_cbs,
+                                      uint32_t migration_flags);
 void red_channel_set_stat_node(RedChannel *channel, StatNodeRef stat);
 
 void red_channel_register_client_cbs(RedChannel *channel, const ClientCbs *client_cbs);
@@ -392,7 +395,7 @@ RedChannelClient *red_channel_client_create(int size, RedChannel *channel, RedCl
 // TODO: tmp, for channels that don't use RedChannel yet (e.g., snd channel), but
 // do use the client callbacks. So the channel clients are not connected (the channel doesn't
 // have list of them, but they do have a link to the channel, and the client has a list of them)
-RedChannel *red_channel_create_dummy(int size, uint32_t type, uint32_t id);
+RedChannel *red_channel_create_dummy(int size, struct RedsState *reds, uint32_t type, uint32_t id);
 RedChannelClient *red_channel_client_create_dummy(int size,
                                                   RedChannel *channel,
                                                   RedClient  *client,
diff --git a/server/red-worker.c b/server/red-worker.c
index ff68499..1d175cf 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -499,7 +499,7 @@ CommonChannel *red_worker_new_channel(RedWorker *worker, int size,
     channel_cbs->alloc_recv_buf = common_alloc_recv_buf;
     channel_cbs->release_recv_buf = common_release_recv_buf;
 
-    channel = red_channel_create_parser(size, &worker->core,
+    channel = red_channel_create_parser(size, reds, &worker->core,
                                         channel_type, worker->qxl->id,
                                         TRUE /* handle_acks */,
                                         spice_get_client_channel_parser(channel_type, NULL),
diff --git a/server/smartcard.c b/server/smartcard.c
index e9e58a8..c7b1f30 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -849,6 +849,7 @@ static void smartcard_init(void)
     channel_cbs.handle_migrate_data = smartcard_channel_client_handle_migrate_data;
 
     g_smartcard_channel = (SmartCardChannel*)red_channel_create(sizeof(SmartCardChannel),
+                                             reds,
                                              reds_get_core_interface(reds),
                                              SPICE_CHANNEL_SMARTCARD, 0,
                                              FALSE /* handle_acks */,
diff --git a/server/sound.c b/server/sound.c
index 3c77d77..fd0b416 100644
--- a/server/sound.c
+++ b/server/sound.c
@@ -1519,7 +1519,7 @@ void snd_attach_playback(SpicePlaybackInstance *sin)
     sin->st->frequency = SND_CODEC_CELT_PLAYBACK_FREQ; /* Default to the legacy rate */
 
     // TODO: Make RedChannel base of worker? instead of assigning it to channel->data
-    channel = red_channel_create_dummy(sizeof(RedChannel), SPICE_CHANNEL_PLAYBACK, 0);
+    channel = red_channel_create_dummy(sizeof(RedChannel), reds, SPICE_CHANNEL_PLAYBACK, 0);
 
     client_cbs.connect = snd_set_playback_peer;
     client_cbs.disconnect = snd_disconnect_channel_client;
@@ -1549,7 +1549,7 @@ void snd_attach_record(SpiceRecordInstance *sin)
     sin->st->frequency = SND_CODEC_CELT_PLAYBACK_FREQ; /* Default to the legacy rate */
 
     // TODO: Make RedChannel base of worker? instead of assigning it to channel->data
-    channel = red_channel_create_dummy(sizeof(RedChannel), SPICE_CHANNEL_RECORD, 0);
+    channel = red_channel_create_dummy(sizeof(RedChannel), reds, SPICE_CHANNEL_RECORD, 0);
 
     client_cbs.connect = snd_set_record_peer;
     client_cbs.disconnect = snd_disconnect_channel_client;
diff --git a/server/spicevmc.c b/server/spicevmc.c
index 4fc95e3..35d1393 100644
--- a/server/spicevmc.c
+++ b/server/spicevmc.c
@@ -524,7 +524,7 @@ SpiceCharDeviceState *spicevmc_device_connect(RedsState *reds,
     channel_cbs.handle_migrate_flush_mark = spicevmc_channel_client_handle_migrate_flush_mark;
     channel_cbs.handle_migrate_data = spicevmc_channel_client_handle_migrate_data;
 
-    state = (SpiceVmcState*)red_channel_create(sizeof(SpiceVmcState),
+    state = (SpiceVmcState*)red_channel_create(sizeof(SpiceVmcState), reds,
                                    reds_get_core_interface(reds), channel_type, id[channel_type]++,
                                    FALSE /* handle_acks */,
                                    spicevmc_red_channel_client_handle_message,


More information about the Spice-commits mailing list