]> git.proxmox.com Git - qemu.git/commitdiff
main-loop: Calculate poll timeout using timeout argument
authorStefan Weil <sw@weilnetz.de>
Sun, 29 Apr 2012 17:15:02 +0000 (19:15 +0200)
committerBlue Swirl <blauwirbel@gmail.com>
Tue, 1 May 2012 10:46:25 +0000 (10:46 +0000)
The timeout argument was unused up to now,
but it can be used to reduce the poll_timeout when it is infinite
(negative value) or larger than timeout.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
main-loop.c

index 24cf540e662e246f3ecadab122f48f1851131888..eb3b6e6253694b2c9f62ccbd7ef431fc78afe800 100644 (file)
@@ -425,7 +425,7 @@ static int os_host_main_loop_wait(uint32_t timeout)
     if (nfds >= 0) {
         ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv0);
         if (ret != 0) {
-            /* TODO. */
+            timeout = 0;
         }
     }
 
@@ -439,6 +439,10 @@ static int os_host_main_loop_wait(uint32_t timeout)
         poll_fds[n_poll_fds + i].events = G_IO_IN;
     }
 
+    if (poll_timeout < 0 || timeout < poll_timeout) {
+        poll_timeout = timeout;
+    }
+
     qemu_mutex_unlock_iothread();
     ret = g_poll(poll_fds, n_poll_fds + w->num, poll_timeout);
     qemu_mutex_lock_iothread();