qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/9] aio: Introduce aio_set_fd_handler_pri


From: Fam Zheng
Subject: [Qemu-devel] [PATCH 1/9] aio: Introduce aio_set_fd_handler_pri
Date: Wed, 10 Jun 2015 16:59:43 +0800

G_IO_PRI event is watched by slirp, add support of that to make future
refactoring possible.

Signed-off-by: Fam Zheng <address@hidden>
---
 aio-posix.c         | 19 +++++++++++++++++++
 aio-win32.c         | 10 ++++++++++
 include/block/aio.h |  8 ++++++++
 3 files changed, 37 insertions(+)

diff --git a/aio-posix.c b/aio-posix.c
index 4abec38..a633c6e 100644
--- a/aio-posix.c
+++ b/aio-posix.c
@@ -23,6 +23,7 @@ struct AioHandler
     GPollFD pfd;
     IOHandler *io_read;
     IOHandler *io_write;
+    IOHandler *io_read_pri;
     int deleted;
     void *opaque;
     QLIST_ENTRY(AioHandler) node;
@@ -47,6 +48,16 @@ void aio_set_fd_handler(AioContext *ctx,
                         IOHandler *io_write,
                         void *opaque)
 {
+    return aio_set_fd_handler_pri(ctx, fd, io_read, io_write, NULL, opaque);
+}
+
+void aio_set_fd_handler_pri(AioContext *ctx,
+                            int fd,
+                            IOHandler *io_read,
+                            IOHandler *io_write,
+                            IOHandler *io_read_pri,
+                            void *opaque)
+{
     AioHandler *node;
 
     node = find_aio_handler(ctx, fd);
@@ -81,10 +92,12 @@ void aio_set_fd_handler(AioContext *ctx,
         /* Update handler with latest information */
         node->io_read = io_read;
         node->io_write = io_write;
+        node->io_read_pri = io_read_pri;
         node->opaque = opaque;
 
         node->pfd.events = (io_read ? G_IO_IN | G_IO_HUP | G_IO_ERR : 0);
         node->pfd.events |= (io_write ? G_IO_OUT | G_IO_ERR : 0);
+        node->pfd.events |= (io_read_pri ? G_IO_PRI | G_IO_HUP | G_IO_ERR : 0);
     }
 
     aio_notify(ctx);
@@ -151,6 +164,12 @@ bool aio_dispatch(AioContext *ctx)
         node->pfd.revents = 0;
 
         if (!node->deleted &&
+            (revents & (G_IO_PRI | G_IO_HUP | G_IO_ERR)) &&
+            node->io_read_pri) {
+            node->io_read_pri(node->opaque);
+            progress = true;
+        }
+        if (!node->deleted &&
             (revents & (G_IO_IN | G_IO_HUP | G_IO_ERR)) &&
             node->io_read) {
             node->io_read(node->opaque);
diff --git a/aio-win32.c b/aio-win32.c
index 233d8f5..016cc19 100644
--- a/aio-win32.c
+++ b/aio-win32.c
@@ -37,6 +37,16 @@ void aio_set_fd_handler(AioContext *ctx,
                         IOHandler *io_write,
                         void *opaque)
 {
+    return aio_set_fd_handler_pri(ctx, fd, io_read, io_write, NULL, opaque);
+}
+
+void aio_set_fd_handler_pri(AioContext *ctx,
+                            int fd,
+                            IOHandler *io_read,
+                            IOHandler *io_write,
+                            IOHandler *io_read_pri,
+                            void *opaque)
+{
     /* fd is a SOCKET in our case */
     AioHandler *node;
 
diff --git a/include/block/aio.h b/include/block/aio.h
index b46103e..82502e1 100644
--- a/include/block/aio.h
+++ b/include/block/aio.h
@@ -253,6 +253,14 @@ void aio_set_fd_handler(AioContext *ctx,
                         IOHandler *io_write,
                         void *opaque);
 
+/* Like aio_set_fd_handler with an additional G_IO_PRI event handler. */
+void aio_set_fd_handler_pri(AioContext *ctx,
+                            int fd,
+                            IOHandler *io_read,
+                            IOHandler *io_write,
+                            IOHandler *io_read_pri,
+                            void *opaque);
+
 /* Register an event notifier and associated callbacks.  Behaves very similarly
  * to event_notifier_set_handler.  Unlike event_notifier_set_handler, these 
callbacks
  * will be invoked when using aio_poll().
-- 
2.4.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]