Patchwork [05/14] Handle deleted IOHandlers in a single pass

login
register
mail settings
Submitter Juan Quintela
Date March 10, 2010, 10:03 a.m.
Message ID <e635bb786bee88ccef430b99e73c2cd202610c16.1268214633.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/47219/
State New
Headers show

Comments

Juan Quintela - March 10, 2010, 10:03 a.m.
Previous code 1st call normal functions and then remove deleted
handlers in the following pass.  Calllapse the two walks.

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

Patch

diff --git a/vl.c b/vl.c
index 354ea31..c2ae185 100644
--- a/vl.c
+++ b/vl.c
@@ -3846,20 +3846,17 @@  void main_loop_wait(int timeout)
     if (ret > 0) {
         IOHandlerRecord *pioh;

-        QTAILQ_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 */
         QTAILQ_FOREACH_SAFE(ioh, &io_handlers, next, pioh) {
             if (ioh->deleted) {
                 QTAILQ_REMOVE(&io_handlers, 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);
             }
         }
     }