[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/2] Use fd signal trick to break us out of sele
Re: [Qemu-devel] [PATCH 1/2] Use fd signal trick to break us out of select; do not sigwait
Thu, 28 Aug 2008 15:16:44 -0500
Thunderbird 188.8.131.52 (X11/20080723)
Ian Jackson wrote:
* Use of SIGUSR2 to interrupt select() does not work because signals
which arrive just before entry to select() do not interrupt it.
* The sigwait approach to detecting aio does not work properly because
some versions of glibc forget to block signals on the private aio
thread under some hard-to-reproduce conditions. This means that
blocking SIGUSR2 is ineffective; the signals can be lost and the
program can block in sigwait (!)
So instead we use the time-honoured self-pipe trick: in the signal
handler we write to a pipe, which we select on when we want to wait
for the signal, and which we read from (to empty out) just before
actually doing the `top half' processing which deals with the condition
to which the signal relates.
We use the existing fd handler infrastructure to run the desired
completion code out of the main event loop; in the aio completion wait
we use a cut-down version of the same arrangements.
Somehow, I didn't see this until today--sorry for the delayed response.
I personally prefer the patch I posted. I've also got another patch on
top of it that refactors the aio API so that multiple aio
implementations can be used. I notice you leave the qemu_aio_poll() in
place in the main loop, is there a reason you left it there?