diff mbox

[2/2] block: avoid SIGUSR2

Message ID 1316433257-4863-3-git-send-email-freddy77@gmail.com
State New
Headers show

Commit Message

Frediano Ziglio Sept. 19, 2011, 11:54 a.m. UTC
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
---
 cpus.c             |    5 -----
 posix-aio-compat.c |   14 ++++----------
 2 files changed, 4 insertions(+), 15 deletions(-)

Comments

Stefan Hajnoczi Sept. 19, 2011, 2:05 p.m. UTC | #1
On Mon, Sep 19, 2011 at 12:54 PM, Frediano Ziglio <freddy77@gmail.com> wrote:
> @@ -547,7 +549,7 @@ static int posix_aio_flush(void *opaque)
>
>  static PosixAioState *posix_aio_state;
>
> -static void aio_signal_handler(int signum)
> +static void posix_aio_notify_event(void)
>  {
>     if (posix_aio_state) {

Seems like this if statement is always true, hence the condition can
be removed.  The posix_aio_state global is always non-NULL here.

Stefan
Christoph Hellwig Sept. 20, 2011, 6:08 p.m. UTC | #2
On Mon, Sep 19, 2011 at 03:05:47PM +0100, Stefan Hajnoczi wrote:
> On Mon, Sep 19, 2011 at 12:54 PM, Frediano Ziglio <freddy77@gmail.com> wrote:
> > @@ -547,7 +549,7 @@ static int posix_aio_flush(void *opaque)
> >
> > ?static PosixAioState *posix_aio_state;
> >
> > -static void aio_signal_handler(int signum)
> > +static void posix_aio_notify_event(void)
> > ?{
> > ? ? if (posix_aio_state) {
> 
> Seems like this if statement is always true, hence the condition can
> be removed.  The posix_aio_state global is always non-NULL here.

It is.  In addition to dropping it I'd also recommend moving the
function up so that it's above it's caller.

Btw, what is the point of the qemu_service_io?  Calling qemu_notify_event
directly would seem a lot more obvious, given that the name actually
gives a hint on what it actually does.
diff mbox

Patch

diff --git a/cpus.c b/cpus.c
index 54c188c..d0cfe91 100644
--- a/cpus.c
+++ b/cpus.c
@@ -380,11 +380,6 @@  static int qemu_signal_init(void)
     int sigfd;
     sigset_t set;
 
-    /* SIGUSR2 used by posix-aio-compat.c */
-    sigemptyset(&set);
-    sigaddset(&set, SIGUSR2);
-    pthread_sigmask(SIG_UNBLOCK, &set, NULL);
-
     /*
      * SIG_IPI must be blocked in the main thread and must not be caught
      * by sigwait() in the signal thread. Otherwise, the cpu thread will
diff --git a/posix-aio-compat.c b/posix-aio-compat.c
index 7ea63a1..72c6dbb 100644
--- a/posix-aio-compat.c
+++ b/posix-aio-compat.c
@@ -308,6 +308,8 @@  static ssize_t handle_aiocb_rw(struct qemu_paiocb *aiocb)
     return nbytes;
 }
 
+static void posix_aio_notify_event(void);
+
 static void *aio_thread(void *unused)
 {
     pid_t pid;
@@ -380,7 +382,7 @@  static void *aio_thread(void *unused)
         aiocb->ret = ret;
         mutex_unlock(&lock);
 
-        if (kill(pid, SIGUSR2)) die("kill failed");
+        posix_aio_notify_event();
     }
 
     cur_threads--;
@@ -547,7 +549,7 @@  static int posix_aio_flush(void *opaque)
 
 static PosixAioState *posix_aio_state;
 
-static void aio_signal_handler(int signum)
+static void posix_aio_notify_event(void)
 {
     if (posix_aio_state) {
         char byte = 0;
@@ -557,8 +559,6 @@  static void aio_signal_handler(int signum)
         if (ret < 0 && errno != EAGAIN)
             die("write()");
     }
-
-    qemu_service_io();
 }
 
 static void paio_remove(struct qemu_paiocb *acb)
@@ -662,7 +662,6 @@  BlockDriverAIOCB *paio_ioctl(BlockDriverState *bs, int fd,
 
 int paio_init(void)
 {
-    struct sigaction act;
     PosixAioState *s;
     int fds[2];
     int ret;
@@ -672,11 +671,6 @@  int paio_init(void)
 
     s = g_malloc(sizeof(PosixAioState));
 
-    sigfillset(&act.sa_mask);
-    act.sa_flags = 0; /* do not restart syscalls to interrupt select() */
-    act.sa_handler = aio_signal_handler;
-    sigaction(SIGUSR2, &act, NULL);
-
     s->first_aio = NULL;
     if (qemu_pipe(fds) == -1) {
         fprintf(stderr, "failed to create pipe\n");