qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH -V2] iohandler: update qemu_fd_set_handler to work with null call back arg
Date: Wed,  7 Sep 2011 18:00:53 +0530	[thread overview]
Message-ID: <1315398653-29945-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> (raw)

Many users of qemu_fd_set_handler including VirtFS use NULL call back arg.
Update fd_trampoline and qemu_fd_set_handler to work with NULL call back arg

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
Changes from V1:
   Add support for dropping event source

 iohandler.c |   31 +++++++++++++------------------
 1 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/iohandler.c b/iohandler.c
index 5ef66fb..783f3ac 100644
--- a/iohandler.c
+++ b/iohandler.c
@@ -93,9 +93,8 @@ static gboolean fd_trampoline(GIOChannel *chan, GIOCondition cond, gpointer opaq
 {
     IOTrampoline *tramp = opaque;
 
-    if (tramp->opaque == NULL) {
+    if (!tramp->fd_read && !tramp->fd_write)
         return FALSE;
-    }
 
     if ((cond & G_IO_IN) && tramp->fd_read) {
         tramp->fd_read(tramp->opaque);
@@ -113,6 +112,7 @@ int qemu_set_fd_handler(int fd,
                         IOHandler *fd_write,
                         void *opaque)
 {
+    GIOCondition cond = 0;
     static IOTrampoline fd_trampolines[FD_SETSIZE];
     IOTrampoline *tramp = &fd_trampolines[fd];
 
@@ -121,25 +121,20 @@ int qemu_set_fd_handler(int fd,
         g_source_remove(tramp->tag);
     }
 
-    if (opaque) {
-        GIOCondition cond = 0;
-
-        tramp->fd_read = fd_read;
-        tramp->fd_write = fd_write;
-        tramp->opaque = opaque;
-
-        if (fd_read) {
-            cond |= G_IO_IN | G_IO_ERR;
-        }
-
-        if (fd_write) {
-            cond |= G_IO_OUT | G_IO_ERR;
-        }
+    if (fd_read) {
+        cond |= G_IO_IN | G_IO_ERR;
+    }
 
-        tramp->chan = g_io_channel_unix_new(fd);
-        tramp->tag = g_io_add_watch(tramp->chan, cond, fd_trampoline, tramp);
+    if (fd_write) {
+        cond |= G_IO_OUT | G_IO_ERR;
     }
 
+    tramp->fd_read = fd_read;
+    tramp->fd_write = fd_write;
+    tramp->opaque = opaque;
+    tramp->chan = g_io_channel_unix_new(fd);
+    tramp->tag = g_io_add_watch(tramp->chan, cond, fd_trampoline, tramp);
+
     return 0;
 }
 
-- 
1.7.4.1

             reply	other threads:[~2011-09-07 12:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-07 12:30 Aneesh Kumar K.V [this message]
2011-09-07 18:44 ` [Qemu-devel] [PATCH -V2] iohandler: update qemu_fd_set_handler to work with null call back arg Anthony Liguori
2011-09-07 19:26   ` Aneesh Kumar K.V
2011-09-08 10:07   ` Avi Kivity
2011-09-08 10:16     ` Kevin Wolf
2011-09-08 12:57     ` Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1315398653-29945-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com \
    --to=aneesh.kumar@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).