Commit 6abfbd79 authored by aliguori's avatar aliguori
Browse files

Use qemu_set_fd_handler2() to determine when alarm timer fires.


Signed-off-by: default avatarAnthony Liguori <aliguori@us.ibm.com>



git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5635 c046a42c-6fe2-441c-8c8c-71466251a162
parent 7183b4b4
...@@ -1689,6 +1689,23 @@ static void win32_rearm_timer(struct qemu_alarm_timer *t) ...@@ -1689,6 +1689,23 @@ static void win32_rearm_timer(struct qemu_alarm_timer *t)
#endif /* _WIN32 */ #endif /* _WIN32 */
static void try_to_rearm_timer(void *opaque)
{
struct qemu_alarm_timer *t = opaque;
ssize_t len;
/* Drain the notify pipe */
do {
char buffer[512];
len = read(alarm_timer_rfd, buffer, sizeof(buffer));
} while ((len == -1 && errno == EINTR) || len > 0);
if (t->flags & ALARM_FLAG_EXPIRED) {
alarm_timer->flags &= ~ALARM_FLAG_EXPIRED;
qemu_rearm_alarm_timer(alarm_timer);
}
}
static int init_timer_alarm(void) static int init_timer_alarm(void)
{ {
struct qemu_alarm_timer *t = NULL; struct qemu_alarm_timer *t = NULL;
...@@ -1723,9 +1740,12 @@ static int init_timer_alarm(void) ...@@ -1723,9 +1740,12 @@ static int init_timer_alarm(void)
goto fail; goto fail;
} }
qemu_set_fd_handler2(alarm_timer_rfd, NULL,
try_to_rearm_timer, NULL, t);
alarm_timer = t; alarm_timer = t;
return 1; return 0;
fail: fail:
close(fds[0]); close(fds[0]);
...@@ -4467,9 +4487,8 @@ void main_loop_wait(int timeout) ...@@ -4467,9 +4487,8 @@ void main_loop_wait(int timeout)
/* poll any events */ /* poll any events */
/* XXX: separate device handlers from system ones */ /* XXX: separate device handlers from system ones */
nfds = alarm_timer_rfd; nfds = -1;
FD_ZERO(&rfds); FD_ZERO(&rfds);
FD_SET(alarm_timer_rfd, &rfds);
FD_ZERO(&wfds); FD_ZERO(&wfds);
FD_ZERO(&xfds); FD_ZERO(&xfds);
for(ioh = first_io_handler; ioh != NULL; ioh = ioh->next) { for(ioh = first_io_handler; ioh != NULL; ioh = ioh->next) {
...@@ -4542,16 +4561,6 @@ void main_loop_wait(int timeout) ...@@ -4542,16 +4561,6 @@ void main_loop_wait(int timeout)
qemu_run_timers(&active_timers[QEMU_TIMER_REALTIME], qemu_run_timers(&active_timers[QEMU_TIMER_REALTIME],
qemu_get_clock(rt_clock)); qemu_get_clock(rt_clock));
if (alarm_timer->flags & ALARM_FLAG_EXPIRED) {
char byte;
do {
ret = read(alarm_timer_rfd, &byte, sizeof(byte));
} while (ret != -1 || errno != EAGAIN);
alarm_timer->flags &= ~(ALARM_FLAG_EXPIRED);
qemu_rearm_alarm_timer(alarm_timer);
}
/* Check bottom-halves last in case any of the earlier events triggered /* Check bottom-halves last in case any of the earlier events triggered
them. */ them. */
qemu_bh_poll(); qemu_bh_poll();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment