All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: qemu-devel@nongnu.org, Jan Kiszka <jan.kiszka@siemens.com>
Subject: Re: [Qemu-devel] [5633] Fix alarm_timer race with select - v3 (Jan Kiszka)
Date: Wed, 05 Nov 2008 15:03:05 -0600	[thread overview]
Message-ID: <49120A09.4010302@codemonkey.ws> (raw)
In-Reply-To: <E1Kxp0c-00080O-8O@cvs.savannah.gnu.org>


> @@ -1674,7 +1678,21 @@
>  {
>      struct qemu_alarm_timer *t = NULL;
>      int i, err = -1;
> +    int fds[2];
>  
> +    if (pipe(fds) < 0) {
> +    fail:
> +        perror("creating timer pipe");
> +        exit(1);
> +    }
>   

pipe() doesn't exist on Windows apparently.  I'm open to suggestions on 
how to fix this properly.  host_alarm_handler isn't a signal handler on 
Windows so perhaps we can just not to the pipe trickery on Windows.

Thoughts?

Regards,

Anthony Liguori

> +    for (i = 0; i < 2; i++) {
> +        int flags = fcntl(fds[i], F_GETFL);
> +        if (flags == -1 || fcntl(fds[i], F_SETFL, flags | O_NONBLOCK))
> +            goto fail;
> +    }
> +    alarm_timer_rfd = fds[0];
> +    alarm_timer_wfd = fds[1];
> +
>      for (i = 0; alarm_timers[i].name; i++) {
>          t = &alarm_timers[i];
>  
> @@ -4426,8 +4444,9 @@
>  
>      /* poll any events */
>      /* XXX: separate device handlers from system ones */
> -    nfds = -1;
> +    nfds = alarm_timer_rfd;
>      FD_ZERO(&rfds);
> +    FD_SET(alarm_timer_rfd, &rfds);
>      FD_ZERO(&wfds);
>      FD_ZERO(&xfds);
>      for(ioh = first_io_handler; ioh != NULL; ioh = ioh->next) {
> @@ -4501,6 +4520,11 @@
>                      qemu_get_clock(rt_clock));
>  
>      if (alarm_timer->flags & ALARM_FLAG_EXPIRED) {
> +        char byte;
> +        do {
> +            ret = read(alarm_timer_rfd, &byte, sizeof(byte));
> +        } while (ret != -1 || errno != EAGAIN);
> +
>          alarm_timer->flags &= ~(ALARM_FLAG_EXPIRED);
>          qemu_rearm_alarm_timer(alarm_timer);
>      }
>
>
>
>
>   

      reply	other threads:[~2008-11-05 21:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-05 20:29 [Qemu-devel] [5633] Fix alarm_timer race with select - v3 (Jan Kiszka) Anthony Liguori
2008-11-05 21:03 ` Anthony Liguori [this message]

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=49120A09.4010302@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=jan.kiszka@siemens.com \
    --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 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.