summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcelo Tosatti <mtosatti@redhat.com>2009-09-29 09:40:29 -0300
committerMarcelo Tosatti <mtosatti@redhat.com>2009-09-29 09:40:29 -0300
commit96db1a0255d1f20ad4953bd9eef9ca51bdd99982 (patch)
treed4c8bc5a83b11f56bf04a4e7dbfd146f1ce762f7 /posix-aio-compat.c
parentMerge commit '075e36b8ede5409b491abdf69fe2ffcf1bfe6bca' into upstream-merge (diff)
parentposix-aio-compat: avoid signal race when spawning a thread (diff)
downloadqemu-kvm-96db1a0255d1f20ad4953bd9eef9ca51bdd99982.tar.gz
qemu-kvm-96db1a0255d1f20ad4953bd9eef9ca51bdd99982.tar.bz2
qemu-kvm-96db1a0255d1f20ad4953bd9eef9ca51bdd99982.zip
Merge commit 'ee3993069ff55fa6f1c64daf1e09963e340db8e4' into upstream-merge
* commit 'ee3993069ff55fa6f1c64daf1e09963e340db8e4': posix-aio-compat: avoid signal race when spawning a thread target-i386: kill a tmp register target-i386: use subfi instead of sub with a non-freed constant eepro100: Fix format strings in debug messages eepro100: Replace sprintf by snprintf eepro100: Remove unused code eepro100: Enhanced logging and comments fix -daemonize with kvm Set SDL icon_title when using `-name XXX` for proper gnome-panel window list integration qemu-option: rename bool -> boolean ARM back-end: Use sxt[bh] instructions for ext{8, 6}s Fix and improve qint_from_int64_test monitor: Fix do_wav_capture() argument type Conflicts: vl.c Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'posix-aio-compat.c')
-rw-r--r--posix-aio-compat.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/posix-aio-compat.c b/posix-aio-compat.c
index ca528766a..65f2bfdef 100644
--- a/posix-aio-compat.c
+++ b/posix-aio-compat.c
@@ -302,14 +302,9 @@ static size_t handle_aiocb_rw(struct qemu_paiocb *aiocb)
static void *aio_thread(void *unused)
{
pid_t pid;
- sigset_t set;
pid = getpid();
- /* block all signals */
- if (sigfillset(&set)) die("sigfillset");
- if (sigprocmask(SIG_BLOCK, &set, NULL)) die("sigprocmask");
-
while (1) {
struct qemu_paiocb *aiocb;
size_t ret = 0;
@@ -370,9 +365,18 @@ static void *aio_thread(void *unused)
static void spawn_thread(void)
{
+ sigset_t set, oldset;
+
cur_threads++;
idle_threads++;
+
+ /* block all signals */
+ if (sigfillset(&set)) die("sigfillset");
+ if (sigprocmask(SIG_SETMASK, &set, &oldset)) die("sigprocmask");
+
thread_create(&thread_id, &attr, aio_thread, NULL);
+
+ if (sigprocmask(SIG_SETMASK, &oldset, NULL)) die("sigprocmask restore");
}
static void qemu_paio_submit(struct qemu_paiocb *aiocb)