[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 6/6] libxl: events: Document and enforce actual callbacks restriction
libxl_event_register_callbacks cannot reasonably be called while libxl is busy (has outstanding operations and/or enabled events). This is because the previous spec implied (although not entirely clearly) that event hooks would not be called for existing fd and timeout interests. There is thus no way to reliably ensure that libxl would get told about fds and timeouts which it became interested in beforehand. So there have to be no such fds or timeouts, which means that the callbacks must only be registered or changed when the ctx is idle. Document this restriction, and enforce it with a pair of asserts. (It would be nicer, perhaps, to say that the application may not call libxl_osevent_register_hooks other than right after creating the ctx. But there are existing callers, including libvirt, who do it later - even after doing major operations such as domain creation.) Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> --- tools/libxl/libxl_event.c | 2 ++ tools/libxl/libxl_event.h | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index 716f318..45f0871 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -1217,6 +1217,8 @@ void libxl_osevent_register_hooks(libxl_ctx *ctx, { GC_INIT(ctx); CTX_LOCK; + assert(LIBXL_LIST_EMPTY(&ctx->efds)); + assert(LIBXL_TAILQ_EMPTY(&ctx->etimes)); ctx->osevent_hooks = hooks; ctx->osevent_user = user; CTX_UNLOCK; diff --git a/tools/libxl/libxl_event.h b/tools/libxl/libxl_event.h index b5db83c..3c6fcfe 100644 --- a/tools/libxl/libxl_event.h +++ b/tools/libxl/libxl_event.h @@ -124,10 +124,8 @@ void libxl_event_register_callbacks(libxl_ctx *ctx, * different parameters, as the application likes; the most recent * call determines the libxl behaviour. However it is NOT safe to * call _register_callbacks concurrently with, or reentrantly from, - * any other libxl function. - * - * Calls to _register_callbacks do not affect events which have - * already occurred. + * any other libxl function, nor while any event-generation + * facilities are enabled. */ -- 1.7.10.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |