From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Jackson Subject: [PATCH 18/29] libxl: cancellation: Provide explicit internal cancel check API Date: Tue, 10 Feb 2015 20:10:05 +0000 Message-ID: <1423599016-32639-19-git-send-email-ian.jackson@eu.citrix.com> References: <1423599016-32639-1-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1423599016-32639-1-git-send-email-ian.jackson@eu.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@lists.xensource.com Cc: Ian Jackson , Euan Harris List-Id: xen-devel@lists.xenproject.org Some places in libxl which can't handle cancellation via a libxl__ao_cancellable callback might nevertheless benefit from being able to explicitly check for cancellation. Provide the (fairly trivial) internal API function to do this. Signed-off-by: Ian Jackson --- v2: New in this version of the series. --- tools/libxl/libxl_event.c | 11 +++++++++++ tools/libxl/libxl_internal.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index 55013ef..d3658f1 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -2027,6 +2027,17 @@ _hidden int libxl_ao_cancel(libxl_ctx *ctx, const libxl_asyncop_how *how) return rc; } +int libxl__ao_cancelling(libxl__ao *ao) +{ + libxl__ao *root = ao_nested_root(ao); + if (root->cancelling) { + DBG("ao=%p: cancelling at explicit check (root=%p)", ao, root); + return ERROR_CANCELLED; + } + + return 0; +} + int libxl__ao_cancellable_register(libxl__ao_cancellable *canc) { libxl__ao *ao = canc->ao; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 46383c4..6caf042 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -207,6 +207,8 @@ static inline void libxl__ao_cancellable_init static inline bool libxl__ao_cancellable_isregistered (const libxl__ao_cancellable *c) { return c->registered; } +int libxl__ao_cancelling(libxl__ao *ao); /* -> 0 or ERROR_CANCELLED */ + typedef struct libxl__ev_time libxl__ev_time; typedef void libxl__ev_time_callback(libxl__egc *egc, libxl__ev_time *ev, -- 1.7.10.4