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 <ian.jack...@eu.citrix.com> Acked-by: Ian Campbell <ian.campb...@citrix.com> --- 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 c224715..d7c478c 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -2028,6 +2028,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 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel