@@ -454,6 +454,22 @@ static int os_host_main_loop_wait(uint32_t timeout)
return ret;
}
+ gpollfds_from_select();
+ 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);
+ }
+ }
+ gpollfds_to_select(select_ret);
+
g_main_context_prepare(context, &max_priority);
n_poll_fds = g_main_context_query(context, max_priority, &poll_timeout,
poll_fds, ARRAY_SIZE(poll_fds));
@@ -493,21 +509,6 @@ static int os_host_main_loop_wait(uint32_t timeout)
/* This back-and-forth between GPollFDs and select(2) is temporary. We'll
* drop it in a couple of patches, I promise :).
*/
- gpollfds_from_select();
- 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);
- }
- }
- gpollfds_to_select(select_ret);
return select_ret || g_poll_ret;
}
The patch for 134a03e0b3d34b01b68107104c525c3bff1211d4 :
@@ -346,6 +346,13 @@ static int os_host_main_loop_wait(uint32_t timeout)
return ret;
}
+ if (nfds >= 0) {
+ select_ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv0);
+ if (select_ret != 0) {
+ timeout = 0;
+ }
+ }
+
g_main_context_prepare(context, &max_priority);
n_poll_fds = g_main_context_query(context, max_priority, &poll_timeout,
poll_fds, ARRAY_SIZE(poll_fds));
@@ -382,12 +389,6 @@ static int os_host_main_loop_wait(uint32_t timeout)
* improve socket latency.
*/
- if (nfds >= 0) {
- select_ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv0);
- if (select_ret != 0) {
- timeout = 0;
- }
- }
return select_ret || g_poll_ret;
}