On 12/07/2017 02:13 PM, Stefan Hajnoczi wrote: > There is a small chance that iothread_stop() hangs as follows: >
> > The bug is explained by the AioContext->notify_me doc comments: > > "If this field is 0, everything (file descriptors, bottom halves, > timers) will be re-evaluated before the next blocking poll(), thus the > event_notifier_set call can be skipped." > > The problem is that "everything" does not include checking > iothread->stopping. This means iothread_run() will block in aio_poll() > if aio_notify() was called just before aio_poll(). > > This patch fixes the hang by replacing aio_notify() with > aio_bh_schedule_oneshot(). This makes aio_poll() or g_main_loop_run() > to return. s/to // > > Implementing this properly required a new bool running flag. The new > flag prevents races that are tricky if we try to use iothread->stopping. > Now iothread->stopping is purely for iothread_stop() and > iothread->running is purely for the iothread_run() thread. > > Signed-off-by: Stefan Hajnoczi <stefa...@redhat.com> > --- > I'm including this patch in this series because it is needed to make the > test case reliable. It's unrelated to the main goal of the patch > series. > --- Reviewed-by: Eric Blake <ebl...@redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature