]> xenbits.xensource.com Git - xen.git/commitdiff
libxl: event handling: ao_inprogress does waits while reports outstanding
authorIan Jackson <ian.jackson@eu.citrix.com>
Mon, 9 Feb 2015 15:20:32 +0000 (15:20 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Wed, 12 Aug 2015 12:09:54 +0000 (13:09 +0100)
libxl__ao_inprogress needs to check (like
libxl__ao_complete_check_progress_reports) that there are no
oustanding progress callbacks.

Otherwise it might happen that we would destroy the ao while another
thread has an outstanding callback its egc report queue.  The other
thread would then, in its egc_run_callbacks, touch the destroyed ao.

Instead, when this happens in libxl__ao_inprogress, simply run round
the event loop again.  The thread which eventually makes the callback
will spot our poller in the ao, and notify the poller, waking us up.

This fixes an assertion failure race seen with libvirt:
  libvirtd: libxl_event.c:1792: libxl__ao_complete_check_progress_reports: Assertion `ao->in_initiator' failed.
or (after "Add an assert to egc_run_callbacks")
  libvirtd: libxl_event.c:1338: egc_run_callbacks: Assertion `aop->ao->magic == 0xA0FACE00ul' failed.

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 f1335f0d7b2402e94e0c6e8a905dc309edaafcfb)
(cherry picked from commit dfed6d96fd6af00c9970e2a1c600d6bb991d137e)
(cherry picked from commit 32f82fa8d9f6ea0eddfd6ab38c0b867b54f99f14)

tools/libxl/libxl_event.c

index 63ba4d2bd39382a0d8fa7656e50d8ad8dae3e0bc..81bb4885a29ae37844797000f384ce361a9315db 100644 (file)
@@ -1679,7 +1679,7 @@ int libxl__ao_inprogress(libxl__ao *ao,
         for (;;) {
             assert(ao->magic == LIBXL__AO_MAGIC);
 
-            if (ao->complete) {
+            if (!ao_work_outstanding(ao)) {
                 rc = ao->rc;
                 ao->notified = 1;
                 break;