Patchwork [10/16] qemu-char:tcp insert poll call into read one

login
register
mail settings
Submitter Juan Quintela
Date March 11, 2010, 4:55 p.m.
Message ID <6fcbaba6d61cb815e58a7c3f5076a39646661026.1268326362.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/47352/
State New
Headers show

Comments

Juan Quintela - March 11, 2010, 4:55 p.m.
This way we can remove the poll test

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

Patch

diff --git a/qemu-char.c b/qemu-char.c
index 93b3ea4..063da94 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -1899,16 +1899,6 @@  static int tcp_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
     }
 }

-static int tcp_chr_read_poll(void *opaque)
-{
-    CharDriverState *chr = opaque;
-    TCPCharDriver *s = chr->opaque;
-    if (!s->connected)
-        return 0;
-    s->max_size = qemu_chr_can_read(chr);
-    return s->max_size;
-}
-
 #define IAC 255
 #define IAC_BREAK 243
 static void tcp_chr_process_IAC_bytes(CharDriverState *chr,
@@ -2030,7 +2020,10 @@  static void tcp_chr_read(void *opaque)
     uint8_t buf[READ_BUF_LEN];
     int len, size;

-    if (!s->connected || s->max_size <= 0)
+    if (!s->connected)
+        return;
+    s->max_size = qemu_chr_can_read(chr);
+    if (s->max_size <= 0)
         return;
     len = sizeof(buf);
     if (len > s->max_size)
@@ -2064,8 +2057,7 @@  static void tcp_chr_connect(void *opaque)
     TCPCharDriver *s = chr->opaque;

     s->connected = 1;
-    qemu_set_fd_handler2(s->fd, tcp_chr_read_poll,
-                         tcp_chr_read, NULL, chr);
+    qemu_set_fd_handler(s->fd, tcp_chr_read, NULL, chr);
     qemu_chr_generic_open(chr);
 }