From: Ian Jackson Date: Mon, 9 Feb 2015 15:18:30 +0000 (+0000) Subject: libxl: event handling: Break out ao_work_outstanding X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=be675bcff3c6316f61debb1d98567841295f127d;p=xen.git libxl: event handling: Break out ao_work_outstanding Break out the test in libxl__ao_complete_check_progress_reports, into ao_work_outstanding, which reports false if either (i) the ao is still ongoing or (ii) there is a progress report (perhaps on a different thread's callback queue) which has yet to be reported to the application. No functional change. Signed-off-by: Ian Jackson CC: Ian Campbell CC: Wei Liu CC: Jim Fehlig Acked-by: Wei Liu (cherry picked from commit 93699882d98cce9736d6e871db303275df1138a2) (cherry picked from commit ba683105b52f60e312151654d72b0b0e8508cee5) (cherry picked from commit 546960ca0572d99edff03fd1eb1436c71ff24d6d) --- diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index 11e37e3918..63ba4d2bd3 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -1574,19 +1574,25 @@ void libxl__ao_complete(libxl__egc *egc, libxl__ao *ao, int rc) libxl__ao_complete_check_progress_reports(egc, ao); } -void libxl__ao_complete_check_progress_reports(libxl__egc *egc, libxl__ao *ao) +static bool ao_work_outstanding(libxl__ao *ao) { /* * We don't consider an ao complete if it has any outstanding * callbacks. These callbacks might be outstanding on other * threads, queued up in the other threads' egc's. Those threads * will, after making the callback, take out the lock again, - * decrement progress_reports_outstanding, and call us again. + * decrement progress_reports_outstanding, and call + * libxl__ao_complete_check_progress_reports. */ + return !ao->complete || ao->progress_reports_outstanding; +} + +void libxl__ao_complete_check_progress_reports(libxl__egc *egc, libxl__ao *ao) +{ libxl_ctx *ctx = libxl__gc_owner(&egc->gc); assert(ao->progress_reports_outstanding >= 0); - if (!ao->complete || ao->progress_reports_outstanding) + if (ao_work_outstanding(ao)) return; if (ao->poller) {