[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 4/4] libxl: events: STATE_AO_GC checks ao is still valid
This will catch earlier the mistake where an ao is completed while it still has events registered: when the event callback happens for the long-gone ao, we will crash before attempting to execute any of the operation-specific code. Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> --- tools/libxl/libxl_event.c | 7 +++++++ tools/libxl/libxl_internal.h | 3 ++- 2 files changed, 9 insertions(+), 1 deletions(-) diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index 0f9ea41..bdbbdd4 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -1399,6 +1399,13 @@ void libxl__ao_abort(libxl__ao *ao) libxl__ao__destroy(CTX, ao); } +libxl__gc *libxl__ao_inprogress_gc(libxl__ao *ao) +{ + assert(ao->magic == LIBXL__AO_MAGIC); + assert(!ao->complete); + return &ao->gc; +} + void libxl__ao_complete(libxl__egc *egc, libxl__ao *ao, int rc) { assert(ao->magic == LIBXL__AO_MAGIC); diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index b2fe8bb..73b9915 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1575,7 +1575,7 @@ _hidden void libxl__egc_cleanup(libxl__egc *egc); #define STATE_AO_GC(op_ao) \ libxl__ao *const ao = (op_ao); \ - AO_GC + libxl__gc *const gc __attribute__((unused)) = libxl__ao_inprogress_gc(ao) /* All of these MUST be called with the ctx locked. @@ -1585,6 +1585,7 @@ _hidden libxl__ao *libxl__ao_create(libxl_ctx*, uint32_t domid, _hidden int libxl__ao_inprogress(libxl__ao *ao); /* temporarily unlocks */ _hidden void libxl__ao_abort(libxl__ao *ao); _hidden void libxl__ao_complete(libxl__egc *egc, libxl__ao *ao, int rc); +_hidden libxl__gc *libxl__ao_inprogress_gc(libxl__ao *ao); /* Can be called at any time. Use is essential for any aop user. */ _hidden void libxl__ao_progress_gethow(libxl_asyncprogress_how *in_state, -- 1.7.2.5 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |