]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commit
virCommand: Don't misuse the eventloop for async IO
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 8 Feb 2013 14:17:44 +0000 (15:17 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 13 Feb 2013 08:54:19 +0000 (09:54 +0100)
commit3178df9afa45cf9d0694536f7fcefd0384def488
treee6bf7abb52d156863daf051209247c3c26ff1b23
parentbbd09adbe231c8c3067512be2b4b7d3ea32cf5fc
virCommand: Don't misuse the eventloop for async IO

Currently, if a command wants to do asynchronous IO, a callback
is registered in the libvirtd eventloop to handle writes and
reads. However, there's a race in virCommandWait. The eventloop
may already be executing the callback, while virCommandWait is
mangling internal state of virCommand. To deal with it, we need
to either introduce locking or spawn a separate thread where we
poll() on stdio from child. The former, however, requires to
unlock all mutexes held, as the event loop may execute other
callbacks which tries to lock one of the mutexes, deadlock and
thus never wake us up. So it's safer to spawn a separate thread.
src/util/vircommand.c