From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41507) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V956G-0004yI-1q for qemu-devel@nongnu.org; Mon, 12 Aug 2013 23:16:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V9567-0007gi-Jb for qemu-devel@nongnu.org; Mon, 12 Aug 2013 23:16:47 -0400 Received: from mail-pb0-x231.google.com ([2607:f8b0:400e:c01::231]:40301) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V9567-0007gY-Cz for qemu-devel@nongnu.org; Mon, 12 Aug 2013 23:16:39 -0400 Received: by mail-pb0-f49.google.com with SMTP id xb4so7407306pbc.36 for ; Mon, 12 Aug 2013 20:16:38 -0700 (PDT) From: Liu Ping Fan Date: Tue, 13 Aug 2013 11:15:41 +0800 Message-Id: <1376363741-19420-4-git-send-email-pingfank@linux.vnet.ibm.com> In-Reply-To: <1376363741-19420-1-git-send-email-pingfank@linux.vnet.ibm.com> References: <1376363741-19420-1-git-send-email-pingfank@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 3/3] slirp: fill mainloop timeout with more precise value List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Stefan Hajnoczi , Jan Kiszka If slirp needs to emulate tcp timeout, then the timeout value for mainloop should be more precise, which is determined by slirp's fasttimo or slowtimo. Signed-off-by: Liu Ping Fan --- main-loop.c | 2 +- slirp/slirp.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/main-loop.c b/main-loop.c index a44fff6..04120d2 100644 --- a/main-loop.c +++ b/main-loop.c @@ -458,8 +458,8 @@ int main_loop_wait(int nonblocking) g_array_set_size(gpollfds, 0); /* reset for new iteration */ /* XXX: separate device handlers from system ones */ #ifdef CONFIG_SLIRP - slirp_update_timeout(&timeout); slirp_pollfds_fill(gpollfds); + slirp_update_timeout(&timeout); #endif qemu_iohandler_fill(gpollfds); ret = os_host_main_loop_wait(timeout); diff --git a/slirp/slirp.c b/slirp/slirp.c index 1deaad9..af66006 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -262,9 +262,27 @@ void slirp_cleanup(Slirp *slirp) void slirp_update_timeout(uint32_t *timeout) { + Slirp *slirp; + if (!QTAILQ_EMPTY(&slirp_instances)) { *timeout = MIN(1000, *timeout); } + if (*timeout <= TIMEOUT_FAST) { + return; + } + + /* If we have tcp timeout with slirp, then we will fill @timeout with + * more precise value. + */ + QTAILQ_FOREACH(slirp, &slirp_instances, entry) { + if (slirp->time_fasttimo) { + *timeout = TIMEOUT_FAST; + break; + } + if (slirp->do_slowtimo) { + *timeout = MIN(TIMEOUT_SLOW, *timeout); + } + } } void slirp_pollfds_fill(GArray *pollfds) -- 1.8.1.4