On 20/07/2015 07:25, Paolo Bonzini wrote:
> >      /* fill pollfds */
> > +    i = 0;
> >      QLIST_FOREACH(node, &ctx->aio_handlers, node) {
> >          if (!node->deleted && node->pfd.events) {
> >              add_pollfd(node);
> > +            if (node->pfd.fd == event_notifier_get_fd(&ctx->notifier)) {
> > +                assert(aio_notifier_idx == -1);
> > +                aio_notifier_idx = i;
> > +            }
> > +            i++;
> >          }
> >      }
>
> That's a good idea.  Since aio_set_fd_handler uses QLIST_INSERT_HEAD,
> perhaps we can be sure that aio_notifier_idx is always the last one
> (i.e. i-1)?  And the same can be done on Windows, I think.

BTW, if this is not true I think I prefer the optimization with atomics.
 But if it's true that we can just use i-1, this one is better.

Paolo

Reply via email to