All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andres Lagar-Cavilla <andres@lagarcavilla.com>
To: Stefano Stabellini <Stefano.Stabellini@eu.citrix.com>,
	xen-devel@lists.xensource.com
Subject: Re: [PATCH] libxenlight: fix multiple xenstore watches problem
Date: Wed, 02 Dec 2009 13:08:24 -0500	[thread overview]
Message-ID: <4B16AD18.6070609@lagarcavilla.com> (raw)
In-Reply-To: <20091202173927.DBE2959805E@homiemail-mx11.g.dreamhost.com>

mmm,
most likely the first two patches in my latest resend clash against 
this. Yikes
Andres
> Message: 3
> Date: Wed, 2 Dec 2009 15:01:32 +0000
> From: Stefano Stabellini<stefano.stabellini@eu.citrix.com>
> Subject: [Xen-devel] [PATCH] libxenlight: fix multiple xenstore
> 	watches	problem
> To: xen-devel@lists.xensource.com
> Message-ID:<alpine.DEB.2.00.0912021455450.26846@kaball-desktop>
> Content-Type: text/plain; charset="US-ASCII"
>
> Hi all,
> this patch fixes the multiple xenstore watches problem in libxenlight
> opening a new xenstore connection to set and read temporary watches on
> the device state nodes.
> This way they don't interfere with other long running watches.
>
> Signed-off-by: Stefano Stabellini<stefano.stabellini@eu.citrix.com>
>
> ---
>
> diff -r 96a9740f4f33 tools/libxl/libxl_device.c
> --- a/tools/libxl/libxl_device.c	Wed Dec 02 14:29:24 2009 +0000
> +++ b/tools/libxl/libxl_device.c	Wed Dec 02 14:43:06 2009 +0000
> @@ -212,47 +212,50 @@
>       fd_set rfds;
>       struct timeval tv;
>       flexarray_t *toremove;
> +    struct libxl_ctx clone = *ctx;
>
> +    clone.xsh = xs_daemon_open();
>       toremove = flexarray_make(16, 1);
> -    path = libxl_sprintf(ctx, "/local/domain/%d/device", domid);
> -    l1 = libxl_xs_directory(ctx, XBT_NULL, path,&num1);
> +    path = libxl_sprintf(&clone, "/local/domain/%d/device", domid);
> +    l1 = libxl_xs_directory(&clone, XBT_NULL, path,&num1);
>       if (!l1) {
> -        XL_LOG(ctx, XL_LOG_ERROR, "%s is empty", path);
> +        XL_LOG(&clone, XL_LOG_ERROR, "%s is empty", path);
> +        xs_daemon_close(clone.xsh);
>           return -1;
>       }
>       for (i = 0; i<  num1; i++) {
> -        path = libxl_sprintf(ctx, "/local/domain/%d/device/%s", domid, l1[i]);
> -        l2 = libxl_xs_directory(ctx, XBT_NULL, path,&num2);
> +        path = libxl_sprintf(&clone, "/local/domain/%d/device/%s", domid, l1[i]);
> +        l2 = libxl_xs_directory(&clone, XBT_NULL, path,&num2);
>           if (!l2)
>               continue;
>           for (j = 0; j<  num2; j++) {
> -            fe_path = libxl_sprintf(ctx, "/local/domain/%d/device/%s/%s", domid, l1[i], l2[j]);
> -            be_path = libxl_xs_read(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/backend", fe_path));
> +            fe_path = libxl_sprintf(&clone, "/local/domain/%d/device/%s/%s", domid, l1[i], l2[j]);
> +            be_path = libxl_xs_read(&clone, XBT_NULL, libxl_sprintf(&clone, "%s/backend", fe_path));
>               if (be_path != NULL) {
> -                if (libxl_device_destroy(ctx, be_path, force)>  0)
> +                if (libxl_device_destroy(&clone, be_path, force)>  0)
>                       n_watches++;
> -                flexarray_set(toremove, n++, libxl_dirname(ctx, be_path));
> +                flexarray_set(toremove, n++, libxl_dirname(&clone, be_path));
>               } else {
> -                xs_rm(ctx->xsh, XBT_NULL, path);
> +                xs_rm(clone.xsh, XBT_NULL, path);
>               }
>           }
>       }
>       if (!force) {
> -        nfds = xs_fileno(ctx->xsh) + 1;
> +        nfds = xs_fileno(clone.xsh) + 1;
>           /* Linux-ism */
>           tv.tv_sec = LIBXL_DESTROY_TIMEOUT;
>           tv.tv_usec = 0;
>           while (n_watches>  0&&  tv.tv_sec>  0) {
>               FD_ZERO(&rfds);
> -            FD_SET(xs_fileno(ctx->xsh),&rfds);
> +            FD_SET(xs_fileno(clone.xsh),&rfds);
>               if (select(nfds,&rfds, NULL, NULL,&tv)>  0) {
> -                l1 = xs_read_watch(ctx->xsh,&num1);
> +                l1 = xs_read_watch(clone.xsh,&num1);
>                   if (l1 != NULL) {
> -                    char *state = libxl_xs_read(ctx, XBT_NULL, l1[0]);
> +                    char *state = libxl_xs_read(&clone, XBT_NULL, l1[0]);
>                       if (!state || atoi(state) == 6) {
> -                        xs_unwatch(ctx->xsh, l1[0], l1[1]);
> -                        xs_rm(ctx->xsh, XBT_NULL, l1[1]);
> -                        XL_LOG(ctx, XL_LOG_DEBUG, "Destroyed device backend at %s", l1[1]);
> +                        xs_unwatch(clone.xsh, l1[0], l1[1]);
> +                        xs_rm(clone.xsh, XBT_NULL, l1[1]);
> +                        XL_LOG(&clone, XL_LOG_DEBUG, "Destroyed device backend at %s", l1[1]);
>                           n_watches--;
>                       }
>                       free(l1);
> @@ -263,9 +266,10 @@
>       }
>       for (i = 0; i<  n; i++) {
>           flexarray_get(toremove, i, (void**)&path);
> -        xs_rm(ctx->xsh, XBT_NULL, path);
> +        xs_rm(clone.xsh, XBT_NULL, path);
>       }
>       flexarray_free(toremove);
> +    xs_daemon_close(clone.xsh);
>       return 0;
>   }
>
>    

       reply	other threads:[~2009-12-02 18:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20091202173927.DBE2959805E@homiemail-mx11.g.dreamhost.com>
2009-12-02 18:08 ` Andres Lagar-Cavilla [this message]
2009-12-02 18:26   ` Re: [PATCH] libxenlight: fix multiple xenstore watches problem Keir Fraser
2009-12-02 15:01 Stefano Stabellini
2009-12-03 15:41 ` Vincent Hanquez
2009-12-03 15:39   ` Stefano Stabellini
2009-12-03 17:08     ` Vincent Hanquez
2009-12-03 18:31       ` Stefano Stabellini
2009-12-03 20:43         ` Stefano Stabellini

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=4B16AD18.6070609@lagarcavilla.com \
    --to=andres@lagarcavilla.com \
    --cc=Stefano.Stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xensource.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.