qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: John Snow <jsnow@redhat.com>
Cc: pl@kamp.de, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/2] ide-test: fix timeouts
Date: Tue, 24 Nov 2015 16:40:18 +0100	[thread overview]
Message-ID: <20151124154018.GH4296@noname.str.redhat.com> (raw)
In-Reply-To: <1448060035-31973-2-git-send-email-jsnow@redhat.com>

Am 20.11.2015 um 23:53 hat John Snow geschrieben:
> Use explicit timeouts instead of trying to fudge
> it by counting nsleep calls.
> 
> Signed-off-by: John Snow <jsnow@redhat.com>

Isn't wrapping lines at 50 characters a bit extreme?

I'm wondering why this is a fix. If anything, I would expect the new
version to be less precise because its resolution is much coarser
(1 s vs. 400 ns). Should still be good enough, so both the new and the
old code look okay to me, but I'd appreciate a commit message that tells
the motivation for this change.

Kevin

>  tests/ide-test.c | 18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/ide-test.c b/tests/ide-test.c
> index fc1ce52..d37dc5e 100644
> --- a/tests/ide-test.c
> +++ b/tests/ide-test.c
> @@ -642,15 +642,20 @@ static void nsleep(int64_t nsecs)
>  
>  static uint8_t ide_wait_clear(uint8_t flag)
>  {
> -    int i;
>      uint8_t data;
> +    time_t st, now;
>  
>      /* Wait with a 5 second timeout */
> -    for (i = 0; i <= 12500000; i++) {
> +    time(&st);
> +    while (true) {
>          data = inb(IDE_BASE + reg_status);
>          if (!(data & flag)) {
>              return data;
>          }
> +        time(&now);
> +        if (difftime(now, st) > 5.0) {
> +            break;
> +        }
>          nsleep(400);
>      }
>      g_assert_not_reached();
> @@ -658,14 +663,19 @@ static uint8_t ide_wait_clear(uint8_t flag)
>  
>  static void ide_wait_intr(int irq)
>  {
> -    int i;
> +    time_t st, now;
>      bool intr;
>  
> -    for (i = 0; i <= 12500000; i++) {
> +    time(&st);
> +    while (true) {
>          intr = get_irq(irq);
>          if (intr) {
>              return;
>          }
> +        time(&now);
> +        if (difftime(now, st) > 5.0) {
> +            break;
> +        }
>          nsleep(400);
>      }
>  
> -- 
> 2.4.3
> 

  reply	other threads:[~2015-11-24 15:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-20 22:53 [Qemu-devel] [PATCH 0/2] ide-test: tidy up after pio race fix John Snow
2015-11-20 22:53 ` [Qemu-devel] [PATCH 1/2] ide-test: fix timeouts John Snow
2015-11-24 15:40   ` Kevin Wolf [this message]
2015-11-24 17:22     ` John Snow
2015-11-20 22:53 ` [Qemu-devel] [PATCH 2/2] ide-test: cdrom_pio_impl fixup John Snow
2015-11-24 15:35   ` Kevin Wolf

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=20151124154018.GH4296@noname.str.redhat.com \
    --to=kwolf@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=pl@kamp.de \
    --cc=qemu-devel@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).