mirror of
https://git.proxmox.com/git/qemu
synced 2025-06-15 20:07:23 +00:00
compatfd: switch to QemuThread
qemu_thread_create already does signal blocking and detaching for us. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
a66670c79c
commit
518420dfec
@ -15,9 +15,9 @@
|
|||||||
|
|
||||||
#include "qemu-common.h"
|
#include "qemu-common.h"
|
||||||
#include "qemu/compatfd.h"
|
#include "qemu/compatfd.h"
|
||||||
|
#include "qemu/thread.h"
|
||||||
|
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
struct sigfd_compat_info
|
struct sigfd_compat_info
|
||||||
{
|
{
|
||||||
@ -28,10 +28,6 @@ struct sigfd_compat_info
|
|||||||
static void *sigwait_compat(void *opaque)
|
static void *sigwait_compat(void *opaque)
|
||||||
{
|
{
|
||||||
struct sigfd_compat_info *info = opaque;
|
struct sigfd_compat_info *info = opaque;
|
||||||
sigset_t all;
|
|
||||||
|
|
||||||
sigfillset(&all);
|
|
||||||
pthread_sigmask(SIG_BLOCK, &all, NULL);
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int sig;
|
int sig;
|
||||||
@ -71,9 +67,8 @@ static void *sigwait_compat(void *opaque)
|
|||||||
|
|
||||||
static int qemu_signalfd_compat(const sigset_t *mask)
|
static int qemu_signalfd_compat(const sigset_t *mask)
|
||||||
{
|
{
|
||||||
pthread_attr_t attr;
|
|
||||||
pthread_t tid;
|
|
||||||
struct sigfd_compat_info *info;
|
struct sigfd_compat_info *info;
|
||||||
|
QemuThread thread;
|
||||||
int fds[2];
|
int fds[2];
|
||||||
|
|
||||||
info = malloc(sizeof(*info));
|
info = malloc(sizeof(*info));
|
||||||
@ -93,12 +88,7 @@ static int qemu_signalfd_compat(const sigset_t *mask)
|
|||||||
memcpy(&info->mask, mask, sizeof(*mask));
|
memcpy(&info->mask, mask, sizeof(*mask));
|
||||||
info->fd = fds[1];
|
info->fd = fds[1];
|
||||||
|
|
||||||
pthread_attr_init(&attr);
|
qemu_thread_create(&thread, sigwait_compat, info, QEMU_THREAD_DETACHED);
|
||||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
|
||||||
|
|
||||||
pthread_create(&tid, &attr, sigwait_compat, info);
|
|
||||||
|
|
||||||
pthread_attr_destroy(&attr);
|
|
||||||
|
|
||||||
return fds[0];
|
return fds[0];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user