summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2001-05-08 13:58:57 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2001-05-08 13:58:57 +0000
commit009fcac6ed116c04b741e564d1dd5f4542e36bec (patch)
tree7a886b31f2d18f9fea2d7e22703817c21a465d10
parent0aa6b610828487a91907c8ee28f71a7169d3c963 (diff)
downloaddrakx-009fcac6ed116c04b741e564d1dd5f4542e36bec.tar
drakx-009fcac6ed116c04b741e564d1dd5f4542e36bec.tar.gz
drakx-009fcac6ed116c04b741e564d1dd5f4542e36bec.tar.bz2
drakx-009fcac6ed116c04b741e564d1dd5f4542e36bec.tar.xz
drakx-009fcac6ed116c04b741e564d1dd5f4542e36bec.zip
use poll() rather than select() to win some bytesCVS: ----------------------------------------------------------------------
-rw-r--r--mdk-stage1/dhcp.c15
1 files changed, 7 insertions, 8 deletions
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 <sys/time.h>
#include <time.h>
#include <fcntl.h>
+#include <sys/poll.h>
#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");