@@ -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
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(-)