From: Paolo Bonzini <pbonzini@redhat.com>
To: Liu Ping Fan <qemulist@gmail.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
qemu-devel@nongnu.org, Anthony Liguori <anthony@codemonkey.ws>,
mdroth <mdroth@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [RFC PATCH v4 12/15] slirp: make timeout local
Date: Thu, 18 Apr 2013 10:22:08 -0400 (EDT) [thread overview]
Message-ID: <469316965.2688793.1366294928597.JavaMail.root@redhat.com> (raw)
In-Reply-To: <1366187964-14265-13-git-send-email-qemulist@gmail.com>
> From: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
>
> Each slirp has its own time to caculate timeout.
Nice cleanup to have anyway upstream.
> Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
> ---
> slirp/slirp.c | 22 ++++++++++------------
> slirp/slirp.h | 3 +++
> 2 files changed, 13 insertions(+), 12 deletions(-)
>
> diff --git a/slirp/slirp.c b/slirp/slirp.c
> index bd9b7cb..5f1c5e8 100644
> --- a/slirp/slirp.c
> +++ b/slirp/slirp.c
> @@ -40,8 +40,6 @@ static const uint8_t special_ethaddr[ETH_ALEN] = {
> static const uint8_t zero_ethaddr[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 };
>
> u_int curtime;
> -static u_int time_fasttimo, last_slowtimo;
> -static int do_slowtimo;
>
> static QTAILQ_HEAD(slirp_instances, Slirp) slirp_instances =
> QTAILQ_HEAD_INITIALIZER(slirp_instances);
> @@ -278,14 +276,14 @@ void slirp_pollfds_fill(GArray *pollfds)
> /*
> * First, TCP sockets
> */
> - do_slowtimo = 0;
>
> QTAILQ_FOREACH(slirp, &slirp_instances, entry) {
> /*
> * *_slowtimo needs calling if there are IP fragments
> * in the fragment queue, or there are TCP connections active
> */
> - do_slowtimo |= ((slirp->tcb.so_next != &slirp->tcb) ||
> + slirp->do_slowtimo = 0;
> + slirp->do_slowtimo |= ((slirp->tcb.so_next != &slirp->tcb) ||
> (&slirp->ipq.ip_link != slirp->ipq.ip_link.next));
No need to do = 0 here.
Paolo
>
> for (so = slirp->tcb.so_next; so != &slirp->tcb;
> @@ -299,8 +297,8 @@ void slirp_pollfds_fill(GArray *pollfds)
> /*
> * See if we need a tcp_fasttimo
> */
> - if (time_fasttimo == 0 && so->so_tcpcb->t_flags & TF_DELACK) {
> - time_fasttimo = curtime; /* Flag when we want a fasttimo */
> + if (slirp->time_fasttimo == 0 && so->so_tcpcb->t_flags & TF_DELACK) {
> + slirp->time_fasttimo = curtime; /* Flag when we want a fasttimo */
> }
>
> /*
> @@ -381,7 +379,7 @@ void slirp_pollfds_fill(GArray *pollfds)
> udp_detach(so);
> continue;
> } else {
> - do_slowtimo = 1; /* Let socket expire */
> + slirp->do_slowtimo = 1; /* Let socket expire */
> }
> }
>
> @@ -422,7 +420,7 @@ void slirp_pollfds_fill(GArray *pollfds)
> icmp_detach(so);
> continue;
> } else {
> - do_slowtimo = 1; /* Let socket expire */
> + slirp->do_slowtimo = 1; /* Let socket expire */
> }
> }
>
> @@ -454,14 +452,14 @@ void slirp_pollfds_poll(GArray *pollfds, int
> select_error)
> /*
> * See if anything has timed out
> */
> - if (time_fasttimo && ((curtime - time_fasttimo) >= 2)) {
> + if (slirp->time_fasttimo && ((curtime - slirp->time_fasttimo) >= 2))
> {
> tcp_fasttimo(slirp);
> - time_fasttimo = 0;
> + slirp->time_fasttimo = 0;
> }
> - if (do_slowtimo && ((curtime - last_slowtimo) >= 499)) {
> + if (slirp->do_slowtimo && ((curtime - slirp->last_slowtimo) >= 499))
> {
> ip_slowtimo(slirp);
> tcp_slowtimo(slirp);
> - last_slowtimo = curtime;
> + slirp->last_slowtimo = curtime;
> }
>
> /*
> diff --git a/slirp/slirp.h b/slirp/slirp.h
> index fe0e65d..008360e 100644
> --- a/slirp/slirp.h
> +++ b/slirp/slirp.h
> @@ -203,6 +203,9 @@ bool arp_table_search(Slirp *slirp, uint32_t ip_addr,
>
> struct Slirp {
> QTAILQ_ENTRY(Slirp) entry;
> + u_int time_fasttimo;
> + u_int last_slowtimo;
> + int do_slowtimo;
>
> /* virtual network configuration */
> struct in_addr vnetwork_addr;
> --
> 1.7.4.4
>
>
next prev parent reply other threads:[~2013-04-18 14:23 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-17 8:39 [Qemu-devel] [RFC PATCH v4 00/15] port network layer onto glib Liu Ping Fan
2013-04-17 8:39 ` [Qemu-devel] [RFC PATCH v4 01/15] util: introduce gsource event abstration Liu Ping Fan
2013-04-18 14:01 ` Stefan Hajnoczi
2013-04-19 6:52 ` liu ping fan
2013-04-19 11:59 ` Stefan Hajnoczi
2013-04-22 7:50 ` liu ping fan
2013-04-17 8:39 ` [Qemu-devel] [RFC PATCH v4 02/15] net: introduce bind_ctx to NetClientInfo Liu Ping Fan
2013-04-17 8:39 ` [Qemu-devel] [RFC PATCH v4 03/15] net: port tap onto GSource Liu Ping Fan
2013-04-17 8:39 ` [Qemu-devel] [RFC PATCH v4 04/15] net: resolve race of tap backend and its peer Liu Ping Fan
2013-04-18 14:11 ` Stefan Hajnoczi
2013-04-19 5:43 ` liu ping fan
2013-04-17 8:39 ` [Qemu-devel] [RFC PATCH v4 05/15] net: port vde onto GSource Liu Ping Fan
2013-04-17 8:39 ` [Qemu-devel] [RFC PATCH v4 06/15] net: port socket to GSource Liu Ping Fan
2013-04-18 14:34 ` Stefan Hajnoczi
2013-04-19 5:58 ` liu ping fan
2013-04-19 12:03 ` Stefan Hajnoczi
2013-04-22 7:52 ` liu ping fan
2013-04-17 8:39 ` [Qemu-devel] [RFC PATCH v4 07/15] net: port tap-win32 onto GSource Liu Ping Fan
2013-04-17 8:39 ` [Qemu-devel] [RFC PATCH v4 08/15] net: hub use lock to protect ports list Liu Ping Fan
2013-04-17 8:39 ` [Qemu-devel] [RFC PATCH v4 09/15] net: introduce lock to protect NetQueue Liu Ping Fan
2013-04-17 8:39 ` [Qemu-devel] [RFC PATCH v4 10/15] net: introduce lock to protect NetClientState's peer's access Liu Ping Fan
2013-04-17 8:39 ` [Qemu-devel] [RFC PATCH v4 11/15] net: make netclient re-entrant with refcnt Liu Ping Fan
2013-04-17 8:39 ` [Qemu-devel] [RFC PATCH v4 12/15] slirp: make timeout local Liu Ping Fan
2013-04-18 14:22 ` Paolo Bonzini [this message]
2013-04-17 8:39 ` [Qemu-devel] [RFC PATCH v4 13/15] slirp: make slirp event dispatch based on slirp instance, not global Liu Ping Fan
2013-04-17 8:39 ` [Qemu-devel] [RFC PATCH v4 14/15] slirp: handle race condition Liu Ping Fan
2013-04-18 7:13 ` Jan Kiszka
2013-04-19 0:18 ` liu ping fan
2013-04-19 8:21 ` Jan Kiszka
2013-04-22 5:55 ` liu ping fan
2013-04-23 7:20 ` liu ping fan
2013-04-17 8:39 ` [Qemu-devel] [RFC PATCH v4 15/15] slirp: use lock to protect the slirp_instances Liu Ping Fan
2013-04-18 7:20 ` Jan Kiszka
2013-04-18 14:16 ` Paolo Bonzini
2013-04-19 6:13 ` liu ping fan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=469316965.2688793.1366294928597.JavaMail.root@redhat.com \
--to=pbonzini@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=jan.kiszka@siemens.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemulist@gmail.com \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.