[Spice-commits] 2 commits - server/dcc.c server/dcc-encoders.c server/dcc-encoders.h
Frediano Ziglio
fziglio at kemper.freedesktop.org
Fri Jan 8 08:26:29 PST 2016
server/dcc-encoders.c | 11 +++++++++++
server/dcc-encoders.h | 2 ++
server/dcc.c | 32 +++++++-------------------------
3 files changed, 20 insertions(+), 25 deletions(-)
New commits:
commit d25d6ca0f26d7a4cc9239ace7f6c0ded6a1ed828
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Tue Dec 22 19:45:22 2015 +0000
dcc: write and use a new encoder_data_reset function to clean buffers
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
diff --git a/server/dcc-encoders.c b/server/dcc-encoders.c
index a373412..26f3070 100644
--- a/server/dcc-encoders.c
+++ b/server/dcc-encoders.c
@@ -150,6 +150,17 @@ void compress_buf_free(RedCompressBuf *buf)
g_slice_free(RedCompressBuf, buf);
}
+void encoder_data_reset(EncoderData *data)
+{
+ RedCompressBuf *buf = data->bufs_head;
+ while (buf) {
+ RedCompressBuf *next = buf->send_next;
+ compress_buf_free(buf);
+ buf = next;
+ }
+ data->bufs_head = data->bufs_tail = NULL;
+}
+
/* Allocate more space for compressed buffer.
* The pointer returned in io_ptr is garanteed to be aligned to 4 bytes.
*/
diff --git a/server/dcc-encoders.h b/server/dcc-encoders.h
index 4e9b66a..7046f1c 100644
--- a/server/dcc-encoders.h
+++ b/server/dcc-encoders.h
@@ -103,6 +103,8 @@ typedef struct {
char message_buf[512];
} EncoderData;
+void encoder_data_reset(EncoderData *data);
+
typedef struct {
QuicUsrContext usr;
EncoderData data;
diff --git a/server/dcc.c b/server/dcc.c
index 7348627..c23936a 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -702,19 +702,10 @@ int dcc_compress_image_glz(DisplayChannelClient *dcc,
// the compressed buffer is bigger than the original data
if (zlib_size >= glz_size) {
- while (zlib_data->data.bufs_head) {
- RedCompressBuf *buf = zlib_data->data.bufs_head;
- zlib_data->data.bufs_head = buf->send_next;
- compress_buf_free(buf);
- }
+ encoder_data_reset(&zlib_data->data);
goto glz;
} else {
- while (glz_data->data.bufs_head) {
- RedCompressBuf *buf = glz_data->data.bufs_head;
- glz_data->data.bufs_head = buf->send_next;
- compress_buf_free(buf);
- }
- glz_data->data.bufs_tail = NULL;
+ encoder_data_reset(&glz_data->data);
}
dest->descriptor.type = SPICE_IMAGE_TYPE_ZLIB_GLZ_RGB;
@@ -753,11 +744,7 @@ int dcc_compress_image_lz(DisplayChannelClient *dcc,
lz_data->data.dcc = dcc;
if (setjmp(lz_data->data.jmp_env)) {
- while (lz_data->data.bufs_head) {
- RedCompressBuf *buf = lz_data->data.bufs_head;
- lz_data->data.bufs_head = buf->send_next;
- compress_buf_free(buf);
- }
+ encoder_data_reset(&lz_data->data);
return FALSE;
}
@@ -846,11 +833,7 @@ int dcc_compress_image_jpeg(DisplayChannelClient *dcc, SpiceImage *dest,
jpeg_data->data.dcc = dcc;
if (setjmp(jpeg_data->data.jmp_env)) {
- while (jpeg_data->data.bufs_head) {
- RedCompressBuf *buf = jpeg_data->data.bufs_head;
- jpeg_data->data.bufs_head = buf->send_next;
- compress_buf_free(buf);
- }
+ encoder_data_reset(&jpeg_data->data);
return FALSE;
}
@@ -957,11 +940,7 @@ int dcc_compress_image_lz4(DisplayChannelClient *dcc, SpiceImage *dest,
lz4_data->data.dcc = dcc;
if (setjmp(lz4_data->data.jmp_env)) {
- while (lz4_data->data.bufs_head) {
- RedCompressBuf *buf = lz4_data->data.bufs_head;
- lz4_data->data.bufs_head = buf->send_next;
- compress_buf_free(buf);
- }
+ encoder_data_reset(&lz4_data->data);
return FALSE;
}
@@ -1028,11 +1007,7 @@ int dcc_compress_image_quic(DisplayChannelClient *dcc, SpiceImage *dest,
quic_data->data.dcc = dcc;
if (setjmp(quic_data->data.jmp_env)) {
- while (quic_data->data.bufs_head) {
- RedCompressBuf *buf = quic_data->data.bufs_head;
- quic_data->data.bufs_head = buf->send_next;
- compress_buf_free(buf);
- }
+ encoder_data_reset(&quic_data->data);
return FALSE;
}
commit bd8c74d7a4cd567c19538e93a8e3ca1742060375
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Thu Jan 7 16:26:16 2016 +0000
dcc: free glz buffer after zlib compression
For zlib+glz compression image if first compressed with glz then the
resulting buffer is compressed again with zlib then the buffer from
zlib is returned to the caller.
However the temporary glz buffer was not freed resulting in a memory
leak.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
diff --git a/server/dcc.c b/server/dcc.c
index 7c16fc0..7348627 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -708,6 +708,13 @@ int dcc_compress_image_glz(DisplayChannelClient *dcc,
compress_buf_free(buf);
}
goto glz;
+ } else {
+ while (glz_data->data.bufs_head) {
+ RedCompressBuf *buf = glz_data->data.bufs_head;
+ glz_data->data.bufs_head = buf->send_next;
+ compress_buf_free(buf);
+ }
+ glz_data->data.bufs_tail = NULL;
}
dest->descriptor.type = SPICE_IMAGE_TYPE_ZLIB_GLZ_RGB;
More information about the Spice-commits
mailing list