]> rtime.felk.cvut.cz Git - lisovros/qemu_apohw.git/commit
Check return values from g_poll and select
authorFabien Chouteau <chouteau@adacore.com>
Tue, 8 Jan 2013 15:30:56 +0000 (16:30 +0100)
committerAnthony Liguori <aliguori@us.ibm.com>
Wed, 9 Jan 2013 17:03:05 +0000 (11:03 -0600)
commit5e3bc735d93dd23f074b5116fd11e1ad8cd4962f
tree384a280b0892ee81c14d00a106627337913748b2
parent7cd5da7eef152a533c5774effd2e7bbfa5976c86
Check return values from g_poll and select

The current implementation of os_host_main_loop_wait() on Windows,
returns 1 only when a g_poll() event occurs because the return value of
select() is overridden. This is wrong as we may skip a socket event, as
shown in this example:

1. select() returns 0
2. g_poll() returns 1  (socket event occurs)
3. os_host_main_loop_wait() returns 1
4. qemu_iohandler_poll() sees no socket event because select() has
   return before the event occurs
5. select() returns 1
6. g_poll() returns 0 (g_poll overrides select's return value)
7. os_host_main_loop_wait() returns 0
8. qemu_iohandler_poll() doesn't check for socket events because the
   return value of os_host_main_loop_wait() is zero.
9. goto 5

This patch use one variable for each of these return values, so we don't
miss a select() event anymore.

Also move the call to select() after g_poll(), this will improve latency
as we don't have to go through two os_host_main_loop_wait() calls to
detect a socket event.

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
main-loop.c