mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2025-12-27 15:45:54 +00:00
Do not access ImageEncoders internal to lock/unlock glz encoding
Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
parent
cc26a9a91e
commit
141bcd1eec
@ -552,6 +552,22 @@ static void red_glz_drawable_free(RedGlzDrawable *glz_drawable)
|
||||
}
|
||||
}
|
||||
|
||||
gboolean image_encoders_glz_encode_lock(ImageEncoders *enc)
|
||||
{
|
||||
if (enc->glz_dict) {
|
||||
pthread_rwlock_wrlock(&enc->glz_dict->encode_lock);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void image_encoders_glz_encode_unlock(ImageEncoders *enc)
|
||||
{
|
||||
if (enc->glz_dict) {
|
||||
pthread_rwlock_unlock(&enc->glz_dict->encode_lock);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove from the global lz dictionary some glz_drawables that have no reference to
|
||||
* Drawable (their qxl drawables are released too).
|
||||
|
||||
@ -48,6 +48,8 @@ void image_encoders_free_glz_drawables_to_free(ImageEncoders* enc);
|
||||
gboolean image_encoders_glz_create(ImageEncoders *enc, uint8_t id);
|
||||
void image_encoders_glz_get_restore_data(ImageEncoders *enc,
|
||||
uint8_t *out_id, GlzEncDictRestoreData *out_data);
|
||||
gboolean image_encoders_glz_encode_lock(ImageEncoders *enc);
|
||||
void image_encoders_glz_encode_unlock(ImageEncoders *enc);
|
||||
void drawable_free_glz_drawables(struct Drawable *drawable);
|
||||
void drawable_detach_glz_drawables(struct Drawable *drawable);
|
||||
|
||||
|
||||
@ -1206,12 +1206,9 @@ void display_channel_free_some(DisplayChannel *display)
|
||||
spice_debug("#draw=%d, #glz_draw=%d", display->drawable_count,
|
||||
display->encoder_shared_data.glz_drawable_count);
|
||||
FOREACH_CLIENT(display, link, next, dcc) {
|
||||
GlzSharedDictionary *glz_dict = dcc->encoders.glz_dict;
|
||||
|
||||
if (glz_dict) {
|
||||
// encoding using the dictionary is prevented since the following operations might
|
||||
// change the dictionary
|
||||
pthread_rwlock_wrlock(&glz_dict->encode_lock);
|
||||
// encoding using the dictionary is prevented since the following operations might
|
||||
// change the dictionary
|
||||
if (image_encoders_glz_encode_lock(&dcc->encoders)) {
|
||||
n = image_encoders_free_some_independent_glz_drawables(&dcc->encoders);
|
||||
}
|
||||
}
|
||||
@ -1221,11 +1218,7 @@ void display_channel_free_some(DisplayChannel *display)
|
||||
}
|
||||
|
||||
FOREACH_CLIENT(display, link, next, dcc) {
|
||||
GlzSharedDictionary *glz_dict = dcc->encoders.glz_dict;
|
||||
|
||||
if (glz_dict) {
|
||||
pthread_rwlock_unlock(&glz_dict->encode_lock);
|
||||
}
|
||||
image_encoders_glz_encode_unlock(&dcc->encoders);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user