OSDN Git Service

do not loop on an incomplete io_thread_fd read
authorPaolo Bonzini <pbonzini@redhat.com>
Tue, 2 Feb 2010 19:33:09 +0000 (20:33 +0100)
committerAnthony Liguori <aliguori@us.ibm.com>
Wed, 10 Feb 2010 17:56:56 +0000 (11:56 -0600)
No need to loop if less than a full buffer is read, the next
read would return EAGAIN.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
vl.c

diff --git a/vl.c b/vl.c
index b87044c..f98661f 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -3229,12 +3229,12 @@ static void qemu_event_read(void *opaque)
 {
     int fd = (unsigned long)opaque;
     ssize_t len;
+    char buffer[512];
 
     /* Drain the notify pipe */
     do {
-        char buffer[512];
         len = read(fd, buffer, sizeof(buffer));
-    } while ((len == -1 && errno == EINTR) || len > 0);
+    } while ((len == -1 && errno == EINTR) || len == sizeof(buffer));
 }
 
 static int qemu_event_init(void)