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

Re: [Xen-devel] [PATCH 05/11] mini-os/xenbus: Use MINIOS_LIST for the list of watches



Ian Jackson, le Fri 20 Jun 2014 20:04:44 +0100, a écrit :
> Remove the open-coded singly-linked list manipulation.
> 
> We replace it with a doubly-linked list because in forthcoming patches
> we are going to want the ability to remove a watch from the middle of
> the list without hunting for it first.
> 
> Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>

Acked-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>

> ---
>  xen/xenbus/xenbus.c |   19 ++++++++++---------
>  1 file changed, 10 insertions(+), 9 deletions(-)
> 
> diff --git a/xen/xenbus/xenbus.c b/xen/xenbus/xenbus.c
> index 8a14c3b..66fdc8a 100644
> --- a/xen/xenbus/xenbus.c
> +++ b/xen/xenbus/xenbus.c
> @@ -49,11 +49,12 @@ static spinlock_t xb_lock = SPIN_LOCK_UNLOCKED; /* 
> protects xenbus req ring */
>  DECLARE_WAIT_QUEUE_HEAD(xenbus_watch_queue);
>  
>  struct xenbus_event_queue xenbus_events;
> -static struct watch {
> +struct watch {
>      char *token;
>      struct xenbus_event_queue *events;
> -    struct watch *next;
> -} *watches;
> +    MINIOS_LIST_ENTRY(watch) entry;
> +};
> +static MINIOS_LIST_HEAD(, watch) watches;
>  struct xenbus_req_info 
>  {
>      int in_use:1;
> @@ -248,7 +249,7 @@ static void xenbus_thread_func(void *ign)
>  
>                  xenstore_buf->rsp_cons += msg.len + sizeof(msg);
>  
> -                for (watch = watches; watch; watch = watch->next)
> +                MINIOS_LIST_FOREACH(watch, &watches, entry)
>                      if (!strcmp(watch->token, event->token)) {
>                          events = watch->events;
>                          break;
> @@ -586,8 +587,8 @@ char* xenbus_watch_path_token( xenbus_transaction_t xbt, 
> const char *path, const
>  
>      watch->token = strdup(token);
>      watch->events = events;
> -    watch->next = watches;
> -    watches = watch;
> +
> +    MINIOS_LIST_INSERT_HEAD(&watches, watch, entry);
>  
>      rep = xenbus_msg_reply(XS_WATCH, xbt, req, ARRAY_SIZE(req));
>  
> @@ -607,7 +608,7 @@ char* xenbus_unwatch_path_token( xenbus_transaction_t 
> xbt, const char *path, con
>       {token, strlen(token) + 1},
>      };
>  
> -    struct watch *watch, **prev;
> +    struct watch *watch;
>  
>      char *msg;
>  
> @@ -617,10 +618,10 @@ char* xenbus_unwatch_path_token( xenbus_transaction_t 
> xbt, const char *path, con
>      if (msg) return msg;
>      free(rep);
>  
> -    for (prev = &watches, watch = *prev; watch; prev = &watch->next, watch = 
> *prev)
> +    MINIOS_LIST_FOREACH(watch, &watches, entry)
>          if (!strcmp(watch->token, token)) {
>              free(watch->token);
> -            *prev = watch->next;
> +            MINIOS_LIST_REMOVE(watch, entry);
>              free(watch);
>              break;
>          }
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxx
> http://lists.xen.org/xen-devel
> 

-- 
Samuel
<xterm> The problem with America is stupidity. I'm not saying there should be a 
capital punishment for stupidity, but why don't we just take the safety labels 
off of everything and let the problem solve itself?

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.