[07/16] Handle deleted IOHandlers in a single buffer

Submitted by Juan Quintela on March 11, 2010, 4:55 p.m.

Details

Message ID fce10713377cb70ca040bda8b8a1a4fc76cd69d3.1268326362.git.quintela@redhat.com
State New
Headers show

Commit Message

Juan Quintela March 11, 2010, 4:55 p.m.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 vl.c |   17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)

Patch hide | download patch | download mbox

diff --git a/vl.c b/vl.c
index e790c6a..52dc4f4 100644
--- a/vl.c
+++ b/vl.c
@@ -3846,20 +3846,17 @@  void main_loop_wait(int timeout)
     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);
             }
         }
     }