Shortly, libxl will be juggling multiple parallel operations, and will
possibly have to take error decisions before some tasks have been set up.

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.coop...@citrix.com>
CC: Ian Campbell <ian.campb...@citrix.com>
CC: Ian Jackson <ian.jack...@eu.citrix.com>
CC: Wei Liu <wei.l...@citrix.com>

---
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
-- 
1.7.10.4


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

Reply via email to