Skip to contentSkip to conversation

main-loop: Calculate poll timeout using timeout argument

PATCH Blue Swirl 1 participant 1 message May 1, 2012 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Blue Swirl

author Applied
#1 lore raw

Thanks, applied.

Quoted 37 lines · Stefan Weil

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.

---
 main-loop.c |    6 +++++-

 1 files changed, 5 insertions(+), 1 deletions(-)
main-loop.c +5 -2
index 24cf540..eb3b6e6 100644
@@ -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();
--

1.7.9