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

Re: [Xen-devel] [PATCH 8/9] libxl: Introduce libxl__ev_devstate



On Fri, 2012-01-13 at 19:25 +0000, Ian Jackson wrote:
> Provide a new-style asynchronous facility for waiting for device
> states on xenbus.  This will replace libxl__wait_for_device_state,
> after the callers have been updated in later patches.

Is event-with-timeout likely to be a useful/common enough pattern to be
worth baking into the infrastructure/helpers rather than implementing
just for this one event type? (if yes then, "I will refactor for the
second user is a valid response").

> Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
> ---
>  tools/libxl/libxl_event.c    |   75 
> ++++++++++++++++++++++++++++++++++++++++++
>  tools/libxl/libxl_internal.h |   41 +++++++++++++++++++++++
>  2 files changed, 116 insertions(+), 0 deletions(-)
> 
> diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c
> index b99049a..1d271b8 100644
> --- a/tools/libxl/libxl_event.c
> +++ b/tools/libxl/libxl_event.c
> @@ -507,6 +507,81 @@ void libxl__ev_xswatch_deregister(libxl__gc *gc, 
> libxl__ev_xswatch *w)
[...]
> +    libxl__ev_devstate_cancel(gc, ds);
> +    ds->callback(egc, ds, rc);
> +}
> +
> +static void devstate_timeout(libxl__egc *egc, libxl__ev_time *ev,
> +                             const struct timeval *requested_abs)
> +{
> +    EGC_GC;
> +    libxl__ev_devstate *ds = CONTAINER_OF(ev, *ds, timeout);
> +    LIBXL__LOG(CTX, LIBXL__LOG_DEBUG, "backend %s wanted state %d "
> +               " timed out", ds->watch.path, ds->wanted);
> +    libxl__ev_devstate_cancel(gc, ds);

What prevents racing here with the watch happening? Might the caller see
two callbacks?

> +    ds->callback(egc, ds, ERROR_TIMEDOUT);
> +}
> +


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

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