]> xenbits.xensource.com Git - xen.git/commitdiff
libxl: events: STATE_AO_GC checks ao is still valid
authorIan Jackson <ian.jackson@eu.citrix.com>
Thu, 17 May 2012 13:45:40 +0000 (14:45 +0100)
committerIan Jackson <ian.jackson@eu.citrix.com>
Thu, 17 May 2012 13:45:40 +0000 (14:45 +0100)
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@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxl/libxl_event.c
tools/libxl/libxl_internal.h

index 03d0498020224f42a42a6c4d5d1fe35a92c5e9a1..350e846aa45f8f830958012c2284d3abeb66e387 100644 (file)
@@ -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);
index b2fe8bb1011fd38fe3242708222259b6b8bce5d9..73b991524e9ca3cde704de7cbfa8df9104b5eb6e 100644 (file)
@@ -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,