Handle deleted IOHandlers in a single buffer
authorJuan Quintela <quintela@redhat.com>
Thu, 11 Mar 2010 16:55:41 +0000 (17:55 +0100)
committerAnthony Liguori <aliguori@us.ibm.com>
Fri, 19 Mar 2010 20:27:27 +0000 (15:27 -0500)
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
vl.c

diff --git a/vl.c b/vl.c
index 1e23d564440383bc714828bb25cd52af9ee364bb..d69250ca2667e4f730348614b8ce4dfd75dc4fb6 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -2836,20 +2836,17 @@ void main_loop_wait(int nonblocking)
     if (ret > 0) {
         IOHandlerRecord *pioh;
 
-        QLIST_FOREACH(ioh, &io_handlers, next) {
-            if (!ioh->deleted && ioh->fd_read && FD_ISSET(ioh->fd, &rfds)) {
-                ioh->fd_read(ioh->opaque);
-            }
-            if (!ioh->deleted && ioh->fd_write && FD_ISSET(ioh->fd, &wfds)) {
-                ioh->fd_write(ioh->opaque);
-            }
-        }
-
-       /* remove deleted IO handlers */
         QLIST_FOREACH_SAFE(ioh, &io_handlers, next, pioh) {
             if (ioh->deleted) {
                 QLIST_REMOVE(ioh, next);
                 qemu_free(ioh);
+                continue;
+            }
+            if (ioh->fd_read && FD_ISSET(ioh->fd, &rfds)) {
+                ioh->fd_read(ioh->opaque);
+            }
+            if (ioh->fd_write && FD_ISSET(ioh->fd, &wfds)) {
+                ioh->fd_write(ioh->opaque);
             }
         }
     }