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

Re: [Xen-devel] [PATCH 09/15] libxl: datacopier: provide "prefix data" facilit



Ian Campbell writes ("Re: [Xen-devel] [PATCH 09/15] libxl: datacopier: provide 
"prefix data" facilit"):
> In the subject: "facility"

Oops, fixed.

> On Wed, 2012-05-30 at 17:16 +0100, Ian Jackson wrote:
> > @@ -1812,6 +1812,12 @@ _hidden void 
> > libxl__datacopier_init(libxl__datacopier_state *dc);
> >  _hidden void libxl__datacopier_kill(libxl__datacopier_state *dc);
> >  _hidden int libxl__datacopier_start(libxl__datacopier_state *dc);
> >  
> > +/* Inserts literal data into the output stream.
> > + * May safely be used only immediately after libxl__datacopier_start.
> 
> After datacopier_start the fds are registered, is there not a race
> between those events firing (perhaps in another thread which has called
> into libxl) and this thread?

No, because we have the ctx mutex held all of the time.

And there isn't a reentrancy hazard either.  As the comments in
libxl_internal.h have it:

   *   int libxl__ev_KIND_register(libxl__gc *gc, libxl__ev_KIND *GEN,
   *                              libxl__ev_KIND_callback *FUNC,
   *                              DETAILS);
   *      [...].  FUNC will
   *      not be called from within the call to _register.  [...]

I think given your question this warrants a comment:

  @@ -78,6 +78,13 @@ void libxl__datacopier_prefixdata(libxl__egc *egc, 
libxl__datacopier_state *dc,
                                     const void *data, size_t len)
   {
       libxl__datacopier_buf *buf;
  +    /*
  +     * It is safe for this to be called immediately after _start, as
  +     * is documented in the public comment.  _start's caller must have
  +     * the mutex locked, so other threads don't get to mess with the
  +     * contents, and the fd events cannot happen reentrantly.  So we
  +     * are guaranteed to beat the first data from the read fd.
  +     */

> Is the safe place not between datacopier_init and the rest of
> datacopier_start?

No, because _start calls _init (just like all the
libxl__*_make_events_happen functions do).

Ian.

_______________________________________________
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®.