提交 3239ad04 编写于 作者: S Stefan Weil 提交者: Blue Swirl

main-loop: Calculate poll timeout using timeout argument

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: NStefan Weil <sw@weilnetz.de>
Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: NBlue Swirl <blauwirbel@gmail.com>
上级 1b296044
......@@ -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();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册