[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [qemu-upstream-unstable] main loop: use msec-based timeout in glib_select_fill



commit 3e21865189962186876483ea1fada46d11818df0
Author: Paolo Bonzini <pbonzini@xxxxxxxxxx>
Date:   Tue Mar 20 10:49:17 2012 +0100

    main loop: use msec-based timeout in glib_select_fill
    
    The timeval-based timeout is not needed until we actually invoke select,
    so compute it only then.  Also group the two calls that modify the
    timeout, glib_select_fill and os_host_main_loop_wait.
    
    upstream-commit: 4dae83aeac63863af6b59f58552da68b35b1a40d
    
    Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
    Signed-off-by: Blue Swirl <blauwirbel@xxxxxxxxx>
---
 main-loop.c |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/main-loop.c b/main-loop.c
index b0f1a04..7cb4d71 100644
--- a/main-loop.c
+++ b/main-loop.c
@@ -223,11 +223,11 @@ static int n_poll_fds;
 static int max_priority;
 
 static void glib_select_fill(int *max_fd, fd_set *rfds, fd_set *wfds,
-                             fd_set *xfds, struct timeval *tv)
+                             fd_set *xfds, uint32_t *cur_timeout)
 {
     GMainContext *context = g_main_context_default();
     int i;
-    int timeout = 0, cur_timeout;
+    int timeout = 0;
 
     g_main_context_prepare(context, &max_priority);
 
@@ -252,10 +252,8 @@ static void glib_select_fill(int *max_fd, fd_set *rfds, 
fd_set *wfds,
         }
     }
 
-    cur_timeout = (tv->tv_sec * 1000) + ((tv->tv_usec + 500) / 1000);
-    if (timeout >= 0 && timeout < cur_timeout) {
-        tv->tv_sec = timeout / 1000;
-        tv->tv_usec = (timeout % 1000) * 1000;
+    if (timeout >= 0 && timeout < *cur_timeout) {
+        *cur_timeout = timeout;
     }
 }
 
@@ -430,8 +428,6 @@ int main_loop_wait(int nonblocking)
         qemu_bh_update_timeout(&timeout);
     }
 
-    os_host_main_loop_wait(&timeout);
-
     /* poll any events */
     /* XXX: separate device handlers from system ones */
     nfds = -1;
@@ -444,7 +440,9 @@ int main_loop_wait(int nonblocking)
     slirp_select_fill(&nfds, &rfds, &wfds, &xfds);
 #endif
     qemu_iohandler_fill(&nfds, &rfds, &wfds, &xfds);
-    glib_select_fill(&nfds, &rfds, &wfds, &xfds, &tv);
+
+    glib_select_fill(&nfds, &rfds, &wfds, &xfds, &timeout);
+    os_host_main_loop_wait(&timeout);
 
     if (timeout < UINT32_MAX) {
         tvarg = &tv;
--
generated by git-patchbot for /home/xen/git/qemu-upstream-unstable.git

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.