[Spice-devel] [PATCH spice-server] worker: Free encoders when client disconnects

Pavel Grunt pgrunt at redhat.com
Fri Nov 20 01:08:07 PST 2015


Signed-off-by: Pavel Grunt <pgrunt at redhat.com>
---
Seems that free functions haven't been used since there were introduced [1]

[1] http://lists.freedesktop.org/archives/spice-devel/2015-November/023893.html
---
 server/dcc-encoders.c | 11 +++++++++++
 server/dcc-encoders.h |  1 +
 server/red_worker.c   |  1 +
 3 files changed, 13 insertions(+)

diff --git a/server/dcc-encoders.c b/server/dcc-encoders.c
index 90d0ce0..6b764ba 100644
--- a/server/dcc-encoders.c
+++ b/server/dcc-encoders.c
@@ -406,6 +406,17 @@ void dcc_encoders_init(DisplayChannelClient *dcc)
     dcc->zlib_level = ZLIB_DEFAULT_COMPRESSION_LEVEL;
 }
 
+void dcc_encoders_free(DisplayChannelClient *dcc)
+{
+    quic_destroy(dcc->quic);
+    lz_destroy(dcc->lz);
+    jpeg_encoder_destroy(dcc->jpeg);
+#ifdef USE_LZ4
+    lz4_encoder_destroy(dcc->lz4);
+#endif
+    zlib_encoder_destroy(dcc->zlib);
+}
+
 static void marshaller_compress_buf_free(uint8_t *data, void *opaque)
 {
     compress_buf_free((RedCompressBuf *) opaque);
diff --git a/server/dcc-encoders.h b/server/dcc-encoders.h
index cdb44ac..30f54d5 100644
--- a/server/dcc-encoders.h
+++ b/server/dcc-encoders.h
@@ -36,6 +36,7 @@ typedef struct RedCompressBuf RedCompressBuf;
 typedef struct GlzDrawableInstanceItem GlzDrawableInstanceItem;
 
 void             dcc_encoders_init                           (DisplayChannelClient *dcc);
+void             dcc_encoders_free                           (DisplayChannelClient *dcc);
 void             dcc_free_glz_drawable_instance              (DisplayChannelClient *dcc,
                                                               GlzDrawableInstanceItem *item);
 void             marshaller_add_compressed                   (SpiceMarshaller *m,
diff --git a/server/red_worker.c b/server/red_worker.c
index 32612d5..cca7f8c 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -5360,6 +5360,7 @@ static void display_channel_client_on_disconnect(RedChannelClient *rcc)
     free(dcc->send_data.stream_outbuf);
     free(dcc->send_data.free_list.res);
     dcc_destroy_stream_agents(dcc);
+    dcc_encoders_free(dcc);
 
     // this was the last channel client
     spice_debug("#draw=%d, #red_draw=%d, #glz_draw=%d",
-- 
2.5.0



More information about the Spice-devel mailing list