From 009fcac6ed116c04b741e564d1dd5f4542e36bec Mon Sep 17 00:00:00 2001 From: Guillaume Cottenceau Date: Tue, 8 May 2001 13:58:57 +0000 Subject: use poll() rather than select() to win some bytesCVS: ---------------------------------------------------------------------- --- mdk-stage1/dhcp.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'mdk-stage1/dhcp.c') diff --git a/mdk-stage1/dhcp.c b/mdk-stage1/dhcp.c index 53ff92617..b886ae3aa 100644 --- a/mdk-stage1/dhcp.c +++ b/mdk-stage1/dhcp.c @@ -40,6 +40,7 @@ #include #include #include +#include #include "stage1.h" #include "log.h" @@ -213,6 +214,7 @@ static void parse_reply(struct bootp_request * breq, struct interface_info * int switch (option) { case BOOTP_OPTION_DNS: memcpy(&dns_server, chptr, sizeof(dns_server)); + log_message("got dns %s", inet_ntoa(dns_server)); if (length >= sizeof(dns_server)*2) memcpy(&dns_server2, chptr+sizeof(dns_server), sizeof(dns_server2)); break; @@ -239,7 +241,7 @@ static void parse_reply(struct bootp_request * breq, struct interface_info * int memcpy(tmp_str, chptr, length); tmp_str[length] = '\0'; hostname = strdup(tmp_str); - log_message("DHCP: got hostname %s", hostname); + log_message("got hostname %s", hostname); break; } @@ -360,8 +362,7 @@ static void rfc951_sleep(int exp) static int handle_transaction(int s, struct bootp_request * breq, struct bootp_request * bresp, struct sockaddr_in * server_addr, int dhcp_type) { - struct timeval tv; - fd_set readfs; + struct pollfd polls; int i, j; int retry = 1; int sin; @@ -390,12 +391,10 @@ static int handle_transaction(int s, struct bootp_request * breq, struct bootp_r return -1; } - FD_ZERO(&readfs); - FD_SET(sin, &readfs); - tv.tv_usec = 0; - tv.tv_sec = timeout; + polls.fd = sin; + polls.events = POLLIN; - while (select(sin + 1, &readfs, NULL, NULL, &tv) == 1) { + while (poll(&polls, 1, timeout*1000) == 1) { if ((j = recv(sin, eth_packet, sizeof(eth_packet), 0)) == -1) { log_perror("recv"); -- cgit v1.2.1