[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 6/7] Teach vnc server to use GThread directly
From: |
Anthony Liguori |
Subject: |
[Qemu-devel] [PATCH 6/7] Teach vnc server to use GThread directly |
Date: |
Mon, 24 Jan 2011 15:00:44 -0600 |
Signed-off-by: Anthony Liguori <address@hidden>
diff --git a/qemu-thread.c b/qemu-thread.c
index 748da5e..6d0c51e 100644
--- a/qemu-thread.c
+++ b/qemu-thread.c
@@ -14,6 +14,31 @@
#include "qemu-common.h"
#include "qemu-thread.h"
+#ifdef _WIN32
+GThread *q_thread_create_nosignal(GThreadFunc func,
+ gpointer data,
+ gboolean joinable,
+ GError **error)
+{
+ return g_thread_create(func, data, joinable, NULL);
+}
+#else
+GThread *q_thread_create_nosignal(GThreadFunc func,
+ gpointer data,
+ gboolean joinable,
+ GError **error)
+{
+ GThread *tid;
+ sigset_t set, old;
+
+ sigfillset(&set);
+ pthread_sigmask(SIG_SETMASK, &set, &old);
+ tid = g_thread_create(func, data, joinable, error);
+ pthread_sigmask(SIG_SETMASK, &old, NULL);
+ return tid;
+}
+#endif
+
struct trampoline_data
{
QemuThread *thread;
diff --git a/qemu-thread.h b/qemu-thread.h
index 2c99c94..ec7fabd 100644
--- a/qemu-thread.h
+++ b/qemu-thread.h
@@ -10,6 +10,11 @@ struct QemuThread {
typedef struct QemuThread QemuThread;
+GThread *q_thread_create_nosignal(GThreadFunc func,
+ gpointer data,
+ gboolean joinable,
+ GError **error);
+
void qemu_thread_create(QemuThread *thread,
void *(*start_routine)(void*),
void *arg);
diff --git a/ui/vnc-jobs-async.c b/ui/vnc-jobs-async.c
index 0c2b1a0..2df245d 100644
--- a/ui/vnc-jobs-async.c
+++ b/ui/vnc-jobs-async.c
@@ -51,7 +51,7 @@
struct VncJobQueue {
GCond *cond;
GStaticMutex mutex;
- QemuThread thread;
+ GThread *thread;
Buffer buffer;
bool exit;
QTAILQ_HEAD(, VncJob) jobs;
@@ -289,11 +289,11 @@ static void vnc_queue_clear(VncJobQueue *q)
queue = NULL; /* Unset global queue */
}
-static void *vnc_worker_thread(void *arg)
+static gpointer vnc_worker_thread(gpointer arg)
{
VncJobQueue *queue = arg;
- qemu_thread_self(&queue->thread);
+ queue->thread = g_thread_self();
while (!vnc_worker_thread_loop(queue)) ;
vnc_queue_clear(queue);
@@ -308,7 +308,7 @@ void vnc_start_worker_thread(void)
return ;
q = vnc_queue_init();
- qemu_thread_create(&q->thread, vnc_worker_thread, q);
+ q->thread = q_thread_create_nosignal(vnc_worker_thread, q, FALSE, NULL);
queue = q; /* Set global queue */
}
--
1.7.0.4
- [Qemu-devel] [PATCH 2/2] vnc: qemu can die if the client is disconnected while updating screen, (continued)
[Qemu-devel] [PATCH 3/7] Add support for glib based threading and convert qemu thread to use it, Anthony Liguori, 2011/01/24
[Qemu-devel] [PATCH 7/7] Rename QemuThread to QemuSThread to indicate that it is not a generic thread, Anthony Liguori, 2011/01/24
[Qemu-devel] [PATCH 6/7] Teach vnc server to use GThread directly,
Anthony Liguori <=
[Qemu-devel] [PATCH 4/7] Get rid of QemuMutex and teach its callers about GStaticMutex, Anthony Liguori, 2011/01/24
[Qemu-devel] [PATCH 1/7] io-thread: make sure to initialize qemu_work_cond and qemu_cpu_cond, Anthony Liguori, 2011/01/24
[Qemu-devel] [PATCH 5/7] threads: get rid of QemuCond and teach callers about GCond, Anthony Liguori, 2011/01/24
[Qemu-devel] Re: [RFC 0/7] Introduce hard dependency on glib, Paolo Bonzini, 2011/01/24