<div dir="ltr"><div><div class="gmail_extra"><div class="gmail_quote">On Tue, Aug 25, 2015 at 11:43 AM, Frediano Ziglio <span dir="ltr"><<a href="mailto:fziglio@redhat.com" target="_blank">fziglio@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Mutex/conditional require Glib 2.32 which is not available in RHEL6.<br>
Use plain pthread to make this module compatible with RHEL6.<br>
<br></blockquote><div><br></div><div>Can't we go for a compat file instead of using plain pthread?<br><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Signed-off-by: Frediano Ziglio <<a href="mailto:fziglio@redhat.com">fziglio@redhat.com</a>><br>
---<br>
server/red_replay_qxl.c | 30 +++++++++++++++---------------<br>
1 file changed, 15 insertions(+), 15 deletions(-)<br>
<br>
diff --git a/server/red_replay_qxl.c b/server/red_replay_qxl.c<br>
index 5044adf..d512a22 100644<br>
--- a/server/red_replay_qxl.c<br>
+++ b/server/red_replay_qxl.c<br>
@@ -22,6 +22,7 @@<br>
#include <stdbool.h><br>
#include <inttypes.h><br>
#include <zlib.h><br>
+#include <pthread.h><br>
#include "reds.h"<br>
#include "red_worker.h"<br>
#include "red_common.h"<br>
@@ -46,9 +47,8 @@ struct SpiceReplay {<br>
GArray *id_free; // free list<br>
int nsurfaces;<br>
<br>
- /* FIXME: some API requires 2.32 */<br>
- GMutex mutex;<br>
- GCond cond;<br>
+ pthread_mutex_t mutex;<br>
+ pthread_cond_t cond;<br>
};<br>
<br>
static int replay_fread(SpiceReplay *replay, uint8_t *buf, size_t size)<br>
@@ -93,13 +93,13 @@ static uint32_t replay_id_get(SpiceReplay *replay, uint32_t id)<br>
if (id == -1)<br>
return id;<br>
<br>
- g_mutex_lock(&replay->mutex);<br>
+ pthread_mutex_lock(&replay->mutex);<br>
if (replay->id_map->len <= id) {<br>
spice_warn_if_reached();<br>
} else {<br>
newid = g_array_index(replay->id_map, uint32_t, id);<br>
}<br>
- g_mutex_unlock(&replay->mutex);<br>
+ pthread_mutex_unlock(&replay->mutex);<br>
<br>
return newid;<br>
}<br>
@@ -109,7 +109,7 @@ static uint32_t replay_id_new(SpiceReplay *replay, uint32_t id)<br>
uint32_t new_id;<br>
uint32_t *map;<br>
<br>
- g_mutex_lock(&replay->mutex);<br>
+ pthread_mutex_lock(&replay->mutex);<br>
while (1) {<br>
if (replay->id_free->len > 0) {<br>
new_id = g_array_index(replay->id_free, uint32_t, 0);<br>
@@ -120,7 +120,7 @@ static uint32_t replay_id_new(SpiceReplay *replay, uint32_t id)<br>
<br>
if (new_id < replay->nsurfaces)<br>
break;<br>
- g_cond_wait(&replay->cond, &replay->mutex);<br>
+ pthread_cond_wait(&replay->cond, &replay->mutex);<br>
}<br>
<br>
if (replay->id_map->len <= id)<br>
@@ -132,7 +132,7 @@ static uint32_t replay_id_new(SpiceReplay *replay, uint32_t id)<br>
*map = new_id;<br>
map = &g_array_index(replay->id_map_inv, uint32_t, new_id);<br>
*map = id;<br>
- g_mutex_unlock(&replay->mutex);<br>
+ pthread_mutex_unlock(&replay->mutex);<br>
<br>
spice_debug("%u -> %u (map %u, inv %u)", id, new_id,<br>
replay->id_map->len, replay->id_map_inv->len);<br>
@@ -145,7 +145,7 @@ static void replay_id_free(SpiceReplay *replay, uint32_t id)<br>
uint32_t old_id;<br>
uint32_t *map;<br>
<br>
- g_mutex_lock(&replay->mutex);<br>
+ pthread_mutex_lock(&replay->mutex);<br>
map = &g_array_index(replay->id_map_inv, uint32_t, id);<br>
old_id = *map;<br>
*map = -1;<br>
@@ -157,8 +157,8 @@ static void replay_id_free(SpiceReplay *replay, uint32_t id)<br>
<br>
g_array_append_val(replay->id_free, id);<br>
}<br>
- g_cond_signal(&replay->cond);<br>
- g_mutex_unlock(&replay->mutex);<br>
+ pthread_cond_signal(&replay->cond);<br>
+ pthread_mutex_unlock(&replay->mutex);<br>
}<br>
<br>
<br>
@@ -1216,8 +1216,8 @@ SpiceReplay *spice_replay_new(FILE *file, int nsurfaces)<br>
replay->eof = 0;<br>
replay->fd = file;<br>
replay->created_primary = FALSE;<br>
- g_mutex_init(&replay->mutex);<br>
- g_cond_init(&replay->cond);<br>
+ pthread_mutex_init(&replay->mutex, NULL);<br>
+ pthread_cond_init(&replay->cond, NULL);<br>
replay->id_map = g_array_new(FALSE, FALSE, sizeof(uint32_t));<br>
replay->id_map_inv = g_array_new(FALSE, FALSE, sizeof(uint32_t));<br>
replay->id_free = g_array_new(FALSE, FALSE, sizeof(uint32_t));<br>
@@ -1233,8 +1233,8 @@ SPICE_GNUC_VISIBLE void spice_replay_free(SpiceReplay *replay)<br>
{<br>
spice_return_if_fail(replay != NULL);<br>
<br>
- g_mutex_clear(&replay->mutex);<br>
- g_cond_clear(&replay->cond);<br>
+ pthread_mutex_destroy(&replay->mutex);<br>
+ pthread_cond_destroy(&replay->cond);<br>
g_array_free(replay->id_map, TRUE);<br>
g_array_free(replay->id_map_inv, TRUE);<br>
g_array_free(replay->id_free, TRUE);<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.4.3<br>
<br>
_______________________________________________<br>
Spice-devel mailing list<br>
<a href="mailto:Spice-devel@lists.freedesktop.org">Spice-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/spice-devel" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/spice-devel</a><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature"><div dir="ltr">Fabiano Fidêncio<br></div></div>
</div></div></div>