[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCHv11 13/31] aio / timers: aio_ctx_prepare sets tim
From: |
Alex Bligh |
Subject: |
Re: [Qemu-devel] [PATCHv11 13/31] aio / timers: aio_ctx_prepare sets timeout from AioContext timers |
Date: |
Tue, 20 Aug 2013 07:48:06 +0100 |
>>
>> for (bh = ctx->first_bh; bh; bh = bh->next) {
>> if (!bh->deleted && bh->scheduled) {
>> if (bh->idle) {
>> /* idle bottom halves will be polled at least
>> * every 10ms */
>> - *timeout = 10;
>> + *timeout = qemu_soonest_timeout(*timeout, 10);
> glib will not set *timeout to a meaningful value before calling
> aio_ctx_prepare(), right? If so, "*timeout = 10" should be used.
I don't think that's correct. Each _prepare routine is called
and has the abilitiy to alter the timeout but need not
set it at all. Indeed it should not set it as there may already
be a shorter timeout there.
Here's the code before I touched it:
aio_ctx_prepare(GSource *source, gint *timeout)
{
AioContext *ctx = (AioContext *) source;
QEMUBH *bh;
for (bh = ctx->first_bh; bh; bh = bh->next) {
if (!bh->deleted && bh->scheduled) {
if (bh->idle) {
/* idle bottom halves will be polled at least
* every 10ms */
*timeout = 10;
} else {
/* non-idle bottom halves will be executed
* immediately */
*timeout = 0;
return true;
}
}
}
return false;
}
You'll note that what this does is:
a) if there are no bottom halves, leaves *timeout as is
b) if there is a non-idle bottom half, set timeout to 0
c) else set timeout to 10 if there are only idle bottom
halves.
Arguably (c) is a bug if timeout was shorter than 10
on entry but the whole of idle bhs are a bit of a bodge.
This is fixed by my series.
If you are asking WHERE it gets set to -1, I don't claim
to be a glib expert but I believe it's the line
gint source_timeout = -1
around line 2816 in glib/gmain.c
--
Alex Bligh
- [Qemu-devel] [PATCHv11 07/31] aio / timers: Make qemu_run_timers and qemu_run_all_timers return progress, (continued)
- [Qemu-devel] [PATCHv11 07/31] aio / timers: Make qemu_run_timers and qemu_run_all_timers return progress, Alex Bligh, 2013/08/15
- [Qemu-devel] [PATCHv11 05/31] aio / timers: add ppoll support with qemu_poll_ns, Alex Bligh, 2013/08/15
- [Qemu-devel] [PATCHv11 01/31] aio / timers: Rename qemu_timer_* functions, Alex Bligh, 2013/08/15
- [Qemu-devel] [PATCHv11 11/31] aio / timers: Add QEMUTimerListGroup to AioContext, Alex Bligh, 2013/08/15
- [Qemu-devel] [PATCHv11 10/31] aio / timers: Add QEMUTimerListGroup and helper functions, Alex Bligh, 2013/08/15
- [Qemu-devel] [PATCHv11 09/31] aio / timers: Untangle include files, Alex Bligh, 2013/08/15
- [Qemu-devel] [PATCHv11 12/31] aio / timers: Add a notify callback to QEMUTimerList, Alex Bligh, 2013/08/15
- [Qemu-devel] [PATCHv11 14/31] aio / timers: Add aio_timer_init & aio_timer_new wrappers, Alex Bligh, 2013/08/15
- [Qemu-devel] [PATCHv11 13/31] aio / timers: aio_ctx_prepare sets timeout from AioContext timers, Alex Bligh, 2013/08/15
Re: [Qemu-devel] [PATCHv11 13/31] aio / timers: aio_ctx_prepare sets timeout from AioContext timers, Stefan Hajnoczi, 2013/08/21
[Qemu-devel] [PATCHv11 17/31] aio / timers: On timer modification, qemu_notify or aio_notify, Alex Bligh, 2013/08/15
[Qemu-devel] [PATCHv11 16/31] aio / timers: Convert mainloop to use timeout, Alex Bligh, 2013/08/15
[Qemu-devel] [PATCHv11 23/31] aio / timers: Add qemu_clock_get_ms and qemu_clock_get_ms, Alex Bligh, 2013/08/15
[Qemu-devel] [PATCHv11 18/31] aio / timers: Introduce new API timer_new and friends, Alex Bligh, 2013/08/15