|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] libxl: events: STATE_AO_GC checks ao is still valid
# HG changeset patch
# User Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
# Date 1337262340 -3600
# Node ID 48598870f55806b7c3fba8dce6882b59e9259a27
# Parent 25bdef4493aefa0b52d9e94271aaf20c17654b87
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>
Committed-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
diff -r 25bdef4493ae -r 48598870f558 tools/libxl/libxl_event.c
--- a/tools/libxl/libxl_event.c Thu May 17 10:37:09 2012 +0100
+++ b/tools/libxl/libxl_event.c Thu May 17 14:45:40 2012 +0100
@@ -1352,6 +1352,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 -r 25bdef4493ae -r 48598870f558 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h Thu May 17 10:37:09 2012 +0100
+++ b/tools/libxl/libxl_internal.h Thu May 17 14:45:40 2012 +0100
@@ -1575,7 +1575,7 @@ _hidden void libxl__egc_cleanup(libxl__e
#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(libx
_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,
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |