提交 ee399306 编写于 作者: M malc

posix-aio-compat: avoid signal race when spawning a thread

Signed-off-by: Nmalc <av1474@comtv.ru>
上级 bedda79c
......@@ -301,14 +301,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;
......@@ -369,9 +364,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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册