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 <Ian.Jackson@eu.citrix.com>
CC: Ian Campbell <ian.campbell@citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Jim Fehlig <jfehlig@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
(cherry picked from commit 93699882d9)
(cherry picked from commit ba683105b5)
This commit is contained in:
Ian Jackson authored and Ian Jackson committed 2015-08-12 12:25:13 +01:00
1 parent 116bbc6062
commit 546960ca05
1 file changed
+9 -3
+9 -3
View File
@@ -1575,19 +1575,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) {
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.