[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 21/42] aio / timers: aio_ctx_prepare sets timeout fro
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 21/42] aio / timers: aio_ctx_prepare sets timeout from AioContext timers |
Date: |
Thu, 22 Aug 2013 22:11:17 +0200 |
From: Alex Bligh <address@hidden>
Calculate the timeout in aio_ctx_prepare taking into account
the timers attached to the AioContext.
Alter aio_ctx_check similarly.
Signed-off-by: Alex Bligh <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
async.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/async.c b/async.c
index cff0ab9..5fb3fa6 100644
--- a/async.c
+++ b/async.c
@@ -150,7 +150,10 @@ aio_ctx_prepare(GSource *source, gint *timeout)
{
AioContext *ctx = (AioContext *) source;
QEMUBH *bh;
+ int deadline;
+ /* We assume there is no timeout already supplied */
+ *timeout = -1;
for (bh = ctx->first_bh; bh; bh = bh->next) {
if (!bh->deleted && bh->scheduled) {
if (bh->idle) {
@@ -166,6 +169,14 @@ aio_ctx_prepare(GSource *source, gint *timeout)
}
}
+ deadline = qemu_timeout_ns_to_ms(timerlistgroup_deadline_ns(&ctx->tlg));
+ if (deadline == 0) {
+ *timeout = 0;
+ return true;
+ } else {
+ *timeout = qemu_soonest_timeout(*timeout, deadline);
+ }
+
return false;
}
@@ -180,7 +191,7 @@ aio_ctx_check(GSource *source)
return true;
}
}
- return aio_pending(ctx);
+ return aio_pending(ctx) || (timerlistgroup_deadline_ns(&ctx->tlg) == 0);
}
static gboolean
--
1.8.3.1
- [Qemu-devel] [PULL 11/42] aio / timers: add qemu-timer.c utility functions, (continued)
- [Qemu-devel] [PULL 11/42] aio / timers: add qemu-timer.c utility functions, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 13/42] aio / timers: add ppoll support with qemu_poll_ns, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 12/42] aio / timers: Consistent treatment of disabled clocks for deadlines, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 14/42] aio / timers: Add prctl(PR_SET_TIMERSLACK, 1, ...) to reduce timer slack, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 15/42] aio / timers: Make qemu_run_timers and qemu_run_all_timers return progress, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 16/42] aio / timers: Split QEMUClock into QEMUClock and QEMUTimerList, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 17/42] aio / timers: Untangle include files, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 18/42] aio / timers: Add QEMUTimerListGroup and helper functions, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 19/42] aio / timers: Add QEMUTimerListGroup to AioContext, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 20/42] aio / timers: Add a notify callback to QEMUTimerList, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 21/42] aio / timers: aio_ctx_prepare sets timeout from AioContext timers,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 22/42] aio / timers: Add aio_timer_init & aio_timer_new wrappers, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 23/42] aio / timers: Convert aio_poll to use AioContext timers' deadline, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 24/42] aio / timers: Convert mainloop to use timeout, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 25/42] aio / timers: On timer modification, qemu_notify or aio_notify, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 27/42] aio / timers: Use all timerlists in icount warp calculations, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 26/42] aio / timers: Introduce new API timer_new and friends, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 28/42] aio / timers: Add documentation and new format calls, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 36/42] aio / timers: Add test harness for AioContext timers, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 34/42] aio / timers: Convert rtc_clock to be a QEMUClockType, Stefan Hajnoczi, 2013/08/22
- [Qemu-devel] [PULL 37/42] aio / timers: Add scripts/switch-timer-api, Stefan Hajnoczi, 2013/08/22