From patchwork Thu Mar 11 16:55:46 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [12/16] qemu-char:pty insert poll call into read one Date: Thu, 11 Mar 2010 06:55:46 -0000 From: Juan Quintela X-Patchwork-Id: 47356 Message-Id: <5ee20f7ebf7038735c337b3175baeedeef342f3d.1268326362.git.quintela@redhat.com> To: qemu-devel@nongnu.org This way we can remove the poll test Signed-off-by: Juan Quintela --- qemu-char.c | 16 +++++----------- 1 files changed, 5 insertions(+), 11 deletions(-) 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