main-loop: partial revert of 5e3bc73
This patch reverts part of 5e3bc735d9
.
Paolo Bonzini wrote this patch and commented:
"WSAEventSelect is edge-triggered and the event will not be signaled if
the socket handler does not consume all the data in the socket buffer."
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1368718561-7816-3-git-send-email-stefanha@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
8db165b36e
commit
3cb8c205e3
32
main-loop.c
32
main-loop.c
@ -394,6 +394,20 @@ static int os_host_main_loop_wait(uint32_t timeout)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FD_ZERO(&rfds);
|
||||||
|
FD_ZERO(&wfds);
|
||||||
|
FD_ZERO(&xfds);
|
||||||
|
nfds = pollfds_fill(gpollfds, &rfds, &wfds, &xfds);
|
||||||
|
if (nfds >= 0) {
|
||||||
|
select_ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv0);
|
||||||
|
if (select_ret != 0) {
|
||||||
|
timeout = 0;
|
||||||
|
}
|
||||||
|
if (select_ret > 0) {
|
||||||
|
pollfds_poll(gpollfds, nfds, &rfds, &wfds, &xfds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
g_main_context_prepare(context, &max_priority);
|
g_main_context_prepare(context, &max_priority);
|
||||||
n_poll_fds = g_main_context_query(context, max_priority, &poll_timeout,
|
n_poll_fds = g_main_context_query(context, max_priority, &poll_timeout,
|
||||||
poll_fds, ARRAY_SIZE(poll_fds));
|
poll_fds, ARRAY_SIZE(poll_fds));
|
||||||
@ -426,24 +440,6 @@ static int os_host_main_loop_wait(uint32_t timeout)
|
|||||||
g_main_context_dispatch(context);
|
g_main_context_dispatch(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Call select after g_poll to avoid a useless iteration and therefore
|
|
||||||
* improve socket latency.
|
|
||||||
*/
|
|
||||||
|
|
||||||
FD_ZERO(&rfds);
|
|
||||||
FD_ZERO(&wfds);
|
|
||||||
FD_ZERO(&xfds);
|
|
||||||
nfds = pollfds_fill(gpollfds, &rfds, &wfds, &xfds);
|
|
||||||
if (nfds >= 0) {
|
|
||||||
select_ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv0);
|
|
||||||
if (select_ret != 0) {
|
|
||||||
timeout = 0;
|
|
||||||
}
|
|
||||||
if (select_ret > 0) {
|
|
||||||
pollfds_poll(gpollfds, nfds, &rfds, &wfds, &xfds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return select_ret || g_poll_ret;
|
return select_ret || g_poll_ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user