ws2_32_new compatibility fixes

- Use Sleep() to wait when we have no interfaces because select() will fail and return without waiting
 - Use WSAGetLastError() instead of errno

svn path=/trunk/; revision=42187
This commit is contained in:
Cameron Gutman 2009-07-25 02:01:13 +00:00
parent 1871ebd28c
commit daba4d6880

View file

@ -63,7 +63,7 @@ void (*bootp_packet_handler)(struct interface_info *,
void void
dispatch(void) dispatch(void)
{ {
int count, i, to_msec, nfds; int count, i, to_msec, nfds, err;
struct protocol *l; struct protocol *l;
fd_set fds; fd_set fds;
time_t howlong, cur_time; time_t howlong, cur_time;
@ -122,10 +122,9 @@ dispatch(void)
} }
if (i == 0) { if (i == 0) {
/* No interfaces for now, set the select timeout reasonably so /* Wait for 5 seconds before looking for more interfaces */
* we can recover from that condition later. */ Sleep(5000);
timeval.tv_sec = 5; continue;
timeval.tv_usec = 0;
} else { } else {
/* Wait for a packet or a timeout... XXX */ /* Wait for a packet or a timeout... XXX */
timeval.tv_sec = to_msec / 1000; timeval.tv_sec = to_msec / 1000;
@ -156,12 +155,9 @@ dispatch(void)
/* Not likely to be transitory... */ /* Not likely to be transitory... */
if (count == SOCKET_ERROR) { if (count == SOCKET_ERROR) {
if (errno == EAGAIN || errno == EINTR) { err = WSAGetLastError();
continue; error("poll: %d", err);
} else { break;
error("poll: %s", strerror(errno));
break;
}
} }
i = 0; i = 0;