Patchwork [10/14] qemu-char:pty insert poll call into read one

login
register
mail settings
Submitter Juan Quintela
Date March 10, 2010, 10:03 a.m.
Message ID <9302ecc91cd65e79b9a4ce1428ec5a52136088d8.1268214633.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/47224/
State New
Headers show

Comments

Juan Quintela - March 10, 2010, 10:03 a.m.
This way we can remove the poll test

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 qemu-char.c |   16 +++++-----------
 1 files changed, 5 insertions(+), 11 deletions(-)

Patch

diff --git a/qemu-char.c b/qemu-char.c
index 875f254..bc294af 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -833,15 +833,6 @@  static int pty_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
     return send_all(s->fd, buf, len);
 }

-static int pty_chr_read_poll(void *opaque)
-{
-    CharDriverState *chr = opaque;
-    PtyCharDriver *s = chr->opaque;
-
-    s->read_bytes = qemu_chr_can_read(chr);
-    return s->read_bytes;
-}
-
 static void pty_chr_read(void *opaque)
 {
     CharDriverState *chr = opaque;
@@ -849,6 +840,10 @@  static void pty_chr_read(void *opaque)
     int size, len;
     uint8_t buf[READ_BUF_LEN];

+    s->read_bytes = qemu_chr_can_read(chr);
+
+    if (s->read_bytes <= 0)
+        return;
     len = sizeof(buf);
     if (len > s->read_bytes)
         len = s->read_bytes;
@@ -870,8 +865,7 @@  static void pty_chr_update_read_handler(CharDriverState *chr)
 {
     PtyCharDriver *s = chr->opaque;

-    qemu_set_fd_handler2(s->fd, pty_chr_read_poll,
-                         pty_chr_read, NULL, chr);
+    qemu_set_fd_handler(s->fd, pty_chr_read, NULL, chr);
     s->polling = 1;
     /*
      * Short timeout here: just need wait long enougth that qemu makes