diff --git a/async.c b/async.c index 85cc641..dd7a24a 100644 --- a/async.c +++ b/async.c @@ -120,7 +120,7 @@ void qemu_bh_delete(QEMUBH *bh) bh->deleted = 1; } -void qemu_bh_update_timeout(uint32_t *timeout) +void qemu_bh_update_timeout(int *timeout) { QEMUBH *bh; diff --git a/main-loop.c b/main-loop.c index eb3b6e6..e248fe2 100644 --- a/main-loop.c +++ b/main-loop.c @@ -226,7 +226,7 @@ static int max_priority; #ifndef _WIN32 static void glib_select_fill(int *max_fd, fd_set *rfds, fd_set *wfds, - fd_set *xfds, uint32_t *cur_timeout) + fd_set *xfds, int *cur_timeout) { GMainContext *context = g_main_context_default(); int i; @@ -288,24 +288,20 @@ static void glib_select_poll(fd_set *rfds, fd_set *wfds, fd_set *xfds, } } -static int os_host_main_loop_wait(uint32_t timeout) +static int os_host_main_loop_wait(int timeout) { - struct timeval tv, *tvarg = NULL; + struct timeval tv; int ret; glib_select_fill(&nfds, &rfds, &wfds, &xfds, &timeout); - if (timeout < UINT32_MAX) { - tvarg = &tv; - tv.tv_sec = timeout / 1000; - tv.tv_usec = (timeout % 1000) * 1000; - } - if (timeout > 0) { qemu_mutex_unlock_iothread(); } - ret = select(nfds + 1, &rfds, &wfds, &xfds, tvarg); + tv.tv_sec = timeout / 1000; + tv.tv_usec = (timeout % 1000) * 1000; + ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv); if (timeout > 0) { qemu_mutex_lock_iothread(); @@ -404,7 +400,7 @@ void qemu_fd_register(int fd) FD_CONNECT | FD_WRITE | FD_OOB); } -static int os_host_main_loop_wait(uint32_t timeout) +static int os_host_main_loop_wait(int timeout) { GMainContext *context = g_main_context_default(); int ret, i; @@ -472,12 +468,12 @@ static int os_host_main_loop_wait(uint32_t timeout) int main_loop_wait(int nonblocking) { - int ret; - uint32_t timeout = UINT32_MAX; + int ret, timeout; if (nonblocking) { timeout = 0; } else { + timeout = qemu_calculate_timeout(); qemu_bh_update_timeout(&timeout); } @@ -489,7 +485,6 @@ int main_loop_wait(int nonblocking) FD_ZERO(&xfds); #ifdef CONFIG_SLIRP - slirp_update_timeout(&timeout); slirp_select_fill(&nfds, &rfds, &wfds, &xfds); #endif qemu_iohandler_fill(&nfds, &rfds, &wfds, &xfds); diff --git a/main-loop.h b/main-loop.h index dce1cd9..925b542 100644 --- a/main-loop.h +++ b/main-loop.h @@ -361,6 +361,6 @@ void qemu_iohandler_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds, int rc void qemu_bh_schedule_idle(QEMUBH *bh); int qemu_bh_poll(void); -void qemu_bh_update_timeout(uint32_t *timeout); +void qemu_bh_update_timeout(int *timeout); #endif diff --git a/qemu-timer.c b/qemu-timer.c index de98977..accd462 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -774,3 +774,8 @@ fail: return err; } +int qemu_calculate_timeout(void) +{ + return 1000; +} + diff --git a/qemu-timer.h b/qemu-timer.h index f8af595..3e61f63 100644 --- a/qemu-timer.h +++ b/qemu-timer.h @@ -60,6 +60,7 @@ uint64_t qemu_timer_expire_time_ns(QEMUTimer *ts); void qemu_run_timers(QEMUClock *clock); void qemu_run_all_timers(void); void configure_alarms(char const *opt); +int qemu_calculate_timeout(void); void init_clocks(void); int init_timer_alarm(void); diff --git a/qemu-tool.c b/qemu-tool.c index 318c5fc..e4e0c7e 100644 --- a/qemu-tool.c +++ b/qemu-tool.c @@ -88,10 +88,6 @@ int qemu_init_main_loop(void) return main_loop_init(); } -void slirp_update_timeout(uint32_t *timeout) -{ -} - void slirp_select_fill(int *pnfds, fd_set *readfds, fd_set *writefds, fd_set *xfds) {