Commit e035649ea3d6d3f845c4ffd686f00dedb9999292

Authored by bellard
1 parent 29e3055c

use a single select for slirp and qemu sockets


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1887 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 16 additions and 21 deletions
@@ -4409,7 +4409,7 @@ void qemu_system_powerdown_request(void) @@ -4409,7 +4409,7 @@ void qemu_system_powerdown_request(void)
4409 void main_loop_wait(int timeout) 4409 void main_loop_wait(int timeout)
4410 { 4410 {
4411 IOHandlerRecord *ioh, *ioh_next; 4411 IOHandlerRecord *ioh, *ioh_next;
4412 - fd_set rfds, wfds; 4412 + fd_set rfds, wfds, xfds;
4413 int ret, nfds; 4413 int ret, nfds;
4414 struct timeval tv; 4414 struct timeval tv;
4415 PollingEntry *pe; 4415 PollingEntry *pe;
@@ -4444,6 +4444,7 @@ void main_loop_wait(int timeout) @@ -4444,6 +4444,7 @@ void main_loop_wait(int timeout)
4444 nfds = -1; 4444 nfds = -1;
4445 FD_ZERO(&rfds); 4445 FD_ZERO(&rfds);
4446 FD_ZERO(&wfds); 4446 FD_ZERO(&wfds);
  4447 + FD_ZERO(&xfds);
4447 for(ioh = first_io_handler; ioh != NULL; ioh = ioh->next) { 4448 for(ioh = first_io_handler; ioh != NULL; ioh = ioh->next) {
4448 if (ioh->fd_read && 4449 if (ioh->fd_read &&
4449 (!ioh->fd_read_poll || 4450 (!ioh->fd_read_poll ||
@@ -4465,7 +4466,12 @@ void main_loop_wait(int timeout) @@ -4465,7 +4466,12 @@ void main_loop_wait(int timeout)
4465 #else 4466 #else
4466 tv.tv_usec = timeout * 1000; 4467 tv.tv_usec = timeout * 1000;
4467 #endif 4468 #endif
4468 - ret = select(nfds + 1, &rfds, &wfds, NULL, &tv); 4469 +#if defined(CONFIG_SLIRP)
  4470 + if (slirp_inited) {
  4471 + slirp_select_fill(&nfds, &rfds, &wfds, &xfds);
  4472 + }
  4473 +#endif
  4474 + ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv);
4469 if (ret > 0) { 4475 if (ret > 0) {
4470 /* XXX: better handling of removal */ 4476 /* XXX: better handling of removal */
4471 for(ioh = first_io_handler; ioh != NULL; ioh = ioh_next) { 4477 for(ioh = first_io_handler; ioh != NULL; ioh = ioh_next) {
@@ -4478,30 +4484,19 @@ void main_loop_wait(int timeout) @@ -4478,30 +4484,19 @@ void main_loop_wait(int timeout)
4478 } 4484 }
4479 } 4485 }
4480 } 4486 }
4481 -#ifdef _WIN32  
4482 - tap_win32_poll();  
4483 -#endif  
4484 -  
4485 #if defined(CONFIG_SLIRP) 4487 #if defined(CONFIG_SLIRP)
4486 - /* XXX: merge with the previous select() */  
4487 if (slirp_inited) { 4488 if (slirp_inited) {
4488 - fd_set rfds, wfds, xfds;  
4489 - int nfds;  
4490 - struct timeval tv;  
4491 -  
4492 - nfds = -1;  
4493 - FD_ZERO(&rfds);  
4494 - FD_ZERO(&wfds);  
4495 - FD_ZERO(&xfds);  
4496 - slirp_select_fill(&nfds, &rfds, &wfds, &xfds);  
4497 - tv.tv_sec = 0;  
4498 - tv.tv_usec = 0;  
4499 - ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv);  
4500 - if (ret >= 0) {  
4501 - slirp_select_poll(&rfds, &wfds, &xfds); 4489 + if (ret < 0) {
  4490 + FD_ZERO(&rfds);
  4491 + FD_ZERO(&wfds);
  4492 + FD_ZERO(&xfds);
4502 } 4493 }
  4494 + slirp_select_poll(&rfds, &wfds, &xfds);
4503 } 4495 }
4504 #endif 4496 #endif
  4497 +#ifdef _WIN32
  4498 + tap_win32_poll();
  4499 +#endif
4505 4500
4506 if (vm_running) { 4501 if (vm_running) {
4507 qemu_run_timers(&active_timers[QEMU_TIMER_VIRTUAL], 4502 qemu_run_timers(&active_timers[QEMU_TIMER_VIRTUAL],