diff options
author | Ian Jackson <ian.jackson@eu.citrix.com> | 2012-05-11 18:59:04 +0100 |
---|---|---|
committer | Ian Jackson <ian.jackson@eu.citrix.com> | 2012-05-11 18:59:04 +0100 |
commit | 738b3d44252221ed3be1a860366a15a2d1b9b091 (patch) | |
tree | 3166a56c4c447c04d7fcef713aede4de7d80c9ae /tools/libxl/libxl_event.c | |
parent | 823c89eeb5b927e735f69901169f280390ed2973 (diff) | |
download | xen-738b3d44252221ed3be1a860366a15a2d1b9b091.tar.gz xen-738b3d44252221ed3be1a860366a15a2d1b9b091.tar.bz2 xen-738b3d44252221ed3be1a860366a15a2d1b9b091.zip |
libxl: Fix an ao completion bug; document locking policy
Document the concurrent access policies for libxl__ao and libxl__egc,
and their corresponding gcs.
Fix a violation of the policy:
If an ao was submitted and a callback requested, and while the
initiating function was still running on the original thread, the ao
is completed on another thread, the completing thread would improperly
concurrently access the ao with the initiating thread.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxl/libxl_event.c')
-rw-r--r-- | tools/libxl/libxl_event.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index 3e784f03f6..b546471a0d 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -901,6 +901,11 @@ void libxl__event_disaster(libxl__egc *egc, const char *msg, int errnoval, static void egc_run_callbacks(libxl__egc *egc) { + /* + * The callbacks must happen with the ctx unlocked. + * See the comment near #define EGC_GC in libxl_internal.h and + * those in the definitions of libxl__egc and libxl__ao. + */ EGC_GC; libxl_event *ev, *ev_tmp; @@ -914,9 +919,11 @@ static void egc_run_callbacks(libxl__egc *egc) entry_for_callback, ao_tmp) { LIBXL_TAILQ_REMOVE(&egc->aos_for_callback, ao, entry_for_callback); ao->how.callback(CTX, ao->rc, ao->how.u.for_callback); + CTX_LOCK; ao->notified = 1; if (!ao->in_initiator) libxl__ao__destroy(CTX, ao); + CTX_UNLOCK; } } |