[Spice-devel] [PATCH 02/30] Move dcc glz field initialization into dcc_new

Frediano Ziglio fziglio at redhat.com
Tue Jun 7 10:17:40 UTC 2016


There is no reason to initialize these fields in two different places.
Note that an usage between dcc_new and the function where these
field were initialised would have resulted in a crash.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/dcc.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/server/dcc.c b/server/dcc.c
index 336bae0..a88f8e6 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -392,6 +392,10 @@ DisplayChannelClient *dcc_new(DisplayChannel *display,
 
     dcc_init_stream_agents(dcc);
 
+    ring_init(&dcc->glz_drawables);
+    ring_init(&dcc->glz_drawables_inst_to_free);
+    pthread_mutex_init(&dcc->glz_drawables_inst_to_free_lock, NULL);
+
     dcc_encoders_init(dcc);
 
     return dcc;
@@ -1371,9 +1375,6 @@ static int dcc_handle_init(DisplayChannelClient *dcc, SpiceMsgcDisplayInit *init
     spice_return_val_if_fail(dcc->pixmap_cache, FALSE);
 
     spice_return_val_if_fail(!dcc->glz_dict, FALSE);
-    ring_init(&dcc->glz_drawables);
-    ring_init(&dcc->glz_drawables_inst_to_free);
-    pthread_mutex_init(&dcc->glz_drawables_inst_to_free_lock, NULL);
     dcc->glz_dict = dcc_get_glz_dictionary(dcc,
                                            init->glz_dictionary_id,
                                            init->glz_dictionary_window_size);
@@ -1479,9 +1480,6 @@ static int dcc_handle_migrate_glz_dictionary(DisplayChannelClient *dcc,
 {
     spice_return_val_if_fail(!dcc->glz_dict, FALSE);
 
-    ring_init(&dcc->glz_drawables);
-    ring_init(&dcc->glz_drawables_inst_to_free);
-    pthread_mutex_init(&dcc->glz_drawables_inst_to_free_lock, NULL);
     dcc->glz_dict = dcc_restore_glz_dictionary(dcc,
                                                migrate->glz_dict_id,
                                                &migrate->glz_dict_data);
-- 
2.7.4



More information about the Spice-devel mailing list