mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2025-12-26 14:41:25 +00:00
dcc: write and use a new encoder_data_reset function to clean buffers
Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Christophe Fergeau <cfergeau@redhat.com>
This commit is contained in:
parent
bd8c74d7a4
commit
d25d6ca0f2
@ -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.
|
||||
*/
|
||||
|
||||
@ -103,6 +103,8 @@ typedef struct {
|
||||
char message_buf[512];
|
||||
} EncoderData;
|
||||
|
||||
void encoder_data_reset(EncoderData *data);
|
||||
|
||||
typedef struct {
|
||||
QuicUsrContext usr;
|
||||
EncoderData data;
|
||||
|
||||
37
server/dcc.c
37
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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user