summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-03-20 10:49:21 +0100
committerBlue Swirl <blauwirbel@gmail.com>2012-04-07 08:34:18 +0000
commitea26ce765cb661a13e4055f38744036a19465e87 (patch)
tree1d72d78effb7ad81c1e0e800bcd348430b29be29
parent06ac7d49797daf8a5c05c7d25db0b205efda8e30 (diff)
downloadhqemu-ea26ce765cb661a13e4055f38744036a19465e87.zip
hqemu-ea26ce765cb661a13e4055f38744036a19465e87.tar.gz
main-loop: integrate glib sources for w32
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
-rw-r--r--main-loop.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/main-loop.c b/main-loop.c
index 4d02568..7e163f9 100644
--- a/main-loop.c
+++ b/main-loop.c
@@ -221,11 +221,10 @@ int main_loop_init(void)
static fd_set rfds, wfds, xfds;
static int nfds;
static GPollFD poll_fds[1024 * 2]; /* this is probably overkill */
-
-#ifndef _WIN32
static int n_poll_fds;
static int max_priority;
+#ifndef _WIN32
static void glib_select_fill(int *max_fd, fd_set *rfds, fd_set *wfds,
fd_set *xfds, int *cur_timeout)
{
@@ -403,6 +402,7 @@ void qemu_fd_register(int fd)
static int os_host_main_loop_wait(int timeout)
{
+ GMainContext *context = g_main_context_default();
int ret, i;
PollingEntry *pe;
WaitObjects *w = &wait_objects;
@@ -424,17 +424,22 @@ static int os_host_main_loop_wait(int timeout)
}
}
+ g_main_context_prepare(context, &max_priority);
+ n_poll_fds = g_main_context_query(context, max_priority, &timeout,
+ poll_fds, ARRAY_SIZE(poll_fds));
+ g_assert(n_poll_fds <= ARRAY_SIZE(poll_fds));
+
for (i = 0; i < w->num; i++) {
- poll_fds[i].fd = (DWORD) w->events[i];
- poll_fds[i].events = G_IO_IN;
+ poll_fds[n_poll_fds + i].fd = (DWORD) w->events[i];
+ poll_fds[n_poll_fds + i].events = G_IO_IN;
}
qemu_mutex_unlock_iothread();
- ret = g_poll(poll_fds, w->num, timeout);
+ ret = g_poll(poll_fds, n_poll_fds + w->num, timeout);
qemu_mutex_lock_iothread();
if (ret > 0) {
for (i = 0; i < w->num; i++) {
- w->revents[i] = poll_fds[i].revents;
+ w->revents[i] = poll_fds[n_poll_fds + i].revents;
}
for (i = 0; i < w->num; i++) {
if (w->revents[i] && w->func[i]) {
@@ -443,6 +448,10 @@ static int os_host_main_loop_wait(int timeout)
}
}
+ if (g_main_context_check(context, max_priority, poll_fds, n_poll_fds)) {
+ g_main_context_dispatch(context);
+ }
+
/* If an edge-triggered socket event occurred, select will return a
* positive result on the next iteration. We do not need to do anything
* here.
OpenPOWER on IntegriCloud