qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 3/3] slirp: fill mainloop timeout with more prec


From: Jan Kiszka
Subject: Re: [Qemu-devel] [PATCH 3/3] slirp: fill mainloop timeout with more precise value
Date: Tue, 13 Aug 2013 10:19:44 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666

On 2013-08-13 05:15, Liu Ping Fan wrote:
> 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 <address@hidden>
> ---
>  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);

Why this reordering?

>  #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)) {

if (QTAILQ_EMPTY(&slirp_instances) || *timeout <= TIMEOUT_FAST) {
    return;
}

*timeout = MIN(1000, *timeout);
...

would be nicer.

>          *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);
> +        }
> +    }

Not sure if the compiler is smart enough, but I would suggest to keep
timeout local until returning and only write it back by then.

Jan

>  }
>  
>  void slirp_pollfds_fill(GArray *pollfds)
> 

-- 
Siemens AG, Corporate Technology, CT RTC ITP SES-DE
Corporate Competence Center Embedded Linux



reply via email to

[Prev in Thread] Current Thread [Next in Thread]