[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 01/27] tools/libxl: Fix libxl__ev_child_inuse() check for not-yet-initialised children
On Mon, 2015-06-15 at 14:44 +0100, Andrew Cooper wrote: > Shortly, libxl will be juggling multiple parallel operations, and will > possibly have to take error decisions before some tasks have been set up. It would be preferable, I think, to arrange to call libxl__ev_child_init on all such libxl__ev_child structs either up front or certainly before there is any possibility of needing to unwind them. Such an init would at worst correspond to exactly the place where the zeroed structure you refer to is zeroed. > No child process of libxl will ever have a pid of 0, so gate > libxl__ev_child_inuse() on a pid strictly greater than 0. > > This makes it safe to use on a zeroed structure of a task which has not yet > been set up. > > Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> > CC: Ian Campbell <Ian.Campbell@xxxxxxxxxx> > CC: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> > CC: Wei Liu <wei.liu2@xxxxxxxxxx> > > --- > This change does make libxl__ev_child_init() functionally useless. I am > undecided between leaving it in place in case it is useful in the future, or > to > remove it completely. > --- > tools/libxl/libxl_internal.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h > index e96d6b5..6226c18 100644 > --- a/tools/libxl/libxl_internal.h > +++ b/tools/libxl/libxl_internal.h > @@ -880,7 +880,7 @@ _hidden pid_t libxl__ev_child_fork(libxl__gc *gc, > libxl__ev_child *childw_out, > static inline void libxl__ev_child_init(libxl__ev_child *childw_out) > { childw_out->pid = -1; } > static inline int libxl__ev_child_inuse(const libxl__ev_child *childw_out) > - { return childw_out->pid >= 0; } > + { return childw_out->pid > 0; } > > /* Useable (only) in the child to once more make the ctx useable for > * xenstore operations. logs failure in the form "what: <error _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |