All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Juan Quintela <quintela@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 03/16] Convert io handlers to QLIST
Date: Mon, 22 Mar 2010 14:40:15 -0500	[thread overview]
Message-ID: <4BA7C79F.8090800@codemonkey.ws> (raw)
In-Reply-To: <b0612c2122e7152b906945ba4f64e9ae2e34aa78.1268326362.git.quintela@redhat.com>

On 03/11/2010 10:55 AM, Juan Quintela wrote:
> Signed-off-by: Juan Quintela<quintela@redhat.com>
>    

Applied 3-7, thanks.

Regards,

Anthony Liguori

> ---
>   vl.c |   35 ++++++++++++++---------------------
>   1 files changed, 14 insertions(+), 21 deletions(-)
>
> diff --git a/vl.c b/vl.c
> index 10d8e34..051eb1c 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2597,10 +2597,12 @@ typedef struct IOHandlerRecord {
>       void *opaque;
>       /* temporary data */
>       struct pollfd *ufd;
> -    struct IOHandlerRecord *next;
> +    QLIST_ENTRY(IOHandlerRecord) next;
>   } IOHandlerRecord;
>
> -static IOHandlerRecord *first_io_handler;
> +static QLIST_HEAD(, IOHandlerRecord) io_handlers =
> +    QLIST_HEAD_INITIALIZER(io_handlers);
> +
>
>   /* XXX: fd_read_poll should be suppressed, but an API change is
>      necessary in the character devices to suppress fd_can_read(). */
> @@ -2610,28 +2612,22 @@ int qemu_set_fd_handler2(int fd,
>                            IOHandler *fd_write,
>                            void *opaque)
>   {
> -    IOHandlerRecord **pioh, *ioh;
> +    IOHandlerRecord *ioh;
>
>       if (!fd_read&&  !fd_write) {
> -        pioh =&first_io_handler;
> -        for(;;) {
> -            ioh = *pioh;
> -            if (ioh == NULL)
> -                break;
> +        QLIST_FOREACH(ioh,&io_handlers, next) {
>               if (ioh->fd == fd) {
>                   ioh->deleted = 1;
>                   break;
>               }
> -            pioh =&ioh->next;
>           }
>       } else {
> -        for(ioh = first_io_handler; ioh != NULL; ioh = ioh->next) {
> +        QLIST_FOREACH(ioh,&io_handlers, next) {
>               if (ioh->fd == fd)
>                   goto found;
>           }
>           ioh = qemu_mallocz(sizeof(IOHandlerRecord));
> -        ioh->next = first_io_handler;
> -        first_io_handler = ioh;
> +        QLIST_INSERT_HEAD(&io_handlers, ioh, next);
>       found:
>           ioh->fd = fd;
>           ioh->fd_read_poll = fd_read_poll;
> @@ -3822,7 +3818,7 @@ void main_loop_wait(int timeout)
>       FD_ZERO(&rfds);
>       FD_ZERO(&wfds);
>       FD_ZERO(&xfds);
> -    for(ioh = first_io_handler; ioh != NULL; ioh = ioh->next) {
> +    QLIST_FOREACH(ioh,&io_handlers, next) {
>           if (ioh->deleted)
>               continue;
>           if (ioh->fd_read&&
> @@ -3848,9 +3844,9 @@ void main_loop_wait(int timeout)
>       ret = select(nfds + 1,&rfds,&wfds,&xfds,&tv);
>       qemu_mutex_lock_iothread();
>       if (ret>  0) {
> -        IOHandlerRecord **pioh;
> +        IOHandlerRecord *pioh;
>
> -        for(ioh = first_io_handler; ioh != NULL; ioh = ioh->next) {
> +        QLIST_FOREACH(ioh,&io_handlers, next) {
>               if (!ioh->deleted&&  ioh->fd_read&&  FD_ISSET(ioh->fd,&rfds)) {
>                   ioh->fd_read(ioh->opaque);
>               }
> @@ -3860,14 +3856,11 @@ void main_loop_wait(int timeout)
>           }
>
>   	/* remove deleted IO handlers */
> -	pioh =&first_io_handler;
> -	while (*pioh) {
> -            ioh = *pioh;
> +        QLIST_FOREACH_SAFE(ioh,&io_handlers, next, pioh) {
>               if (ioh->deleted) {
> -                *pioh = ioh->next;
> +                QLIST_REMOVE(ioh, next);
>                   qemu_free(ioh);
> -            } else
> -                pioh =&ioh->next;
> +            }
>           }
>       }
>
>    

  reply	other threads:[~2010-03-22 19:40 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-11 16:55 [Qemu-devel] [PATCH 00/16] *** SUBJECT HERE *** Juan Quintela
2010-03-11 16:55 ` [Qemu-devel] [PATCH 01/16] migration: Clear fd also in error cases Juan Quintela
2010-03-11 16:55 ` [Qemu-devel] [PATCH 02/16] migration: unix migration should obey autostart are the other ones Juan Quintela
2010-03-11 16:55 ` [Qemu-devel] [PATCH 03/16] Convert io handlers to QLIST Juan Quintela
2010-03-22 19:40   ` Anthony Liguori [this message]
2010-03-11 16:55 ` [Qemu-devel] [PATCH 04/16] remove useless cast Juan Quintela
2010-03-11 16:55 ` [Qemu-devel] [PATCH 05/16] rename IOCanRWHandler to IOCanReadHandler Juan Quintela
2010-03-11 16:55 ` [Qemu-devel] [PATCH 06/16] bt: remove bt_host_read_poll() Juan Quintela
2010-03-11 16:55 ` [Qemu-devel] [PATCH 07/16] Handle deleted IOHandlers in a single buffer Juan Quintela
2010-03-11 16:55 ` [Qemu-devel] [PATCH 08/16] tap: insert tap_can_send() into tap_send() Juan Quintela
2010-03-17 17:52   ` Anthony Liguori
2010-03-11 16:55 ` [Qemu-devel] [PATCH 09/16] qemu-char:stdio insert poll call into read one Juan Quintela
2010-03-11 16:55 ` [Qemu-devel] [PATCH 10/16] qemu-char:tcp " Juan Quintela
2010-03-11 16:55 ` [Qemu-devel] [PATCH 11/16] qemu-char:fd " Juan Quintela
2010-03-11 16:55 ` [Qemu-devel] [PATCH 12/16] qemu-char:pty " Juan Quintela
2010-03-11 16:55 ` [Qemu-devel] [PATCH 13/16] qemu-char:udp " Juan Quintela
2010-03-11 16:55 ` [Qemu-devel] [PATCH 14/16] Remove qemu_set_fd_handler2() Juan Quintela
2010-03-11 16:55 ` [Qemu-devel] [PATCH 15/16] Remove now unused fd_read_poll and all its only left user Juan Quintela
2010-03-11 16:55 ` [Qemu-devel] [PATCH 16/16] Add qemu_remove_fd_handler() Juan Quintela

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=4BA7C79F.8090800@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@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.