From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: [PATCH 01/27] tools/libxl: Fix libxl__ev_child_inuse() check for not-yet-initialised children Date: Mon, 15 Jun 2015 14:44:14 +0100 Message-ID: <1434375880-30914-2-git-send-email-andrew.cooper3@citrix.com> References: <1434375880-30914-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1434375880-30914-1-git-send-email-andrew.cooper3@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: Wei Liu , Yang Hongyang , Ian Jackson , Ian Campbell , Andrew Cooper List-Id: xen-devel@lists.xenproject.org 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 CC: Ian Campbell CC: Ian Jackson CC: Wei Liu --- 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: