Some network handling optimization

This commit is contained in:
simon.kagstrom 2010-03-06 15:34:44 +00:00
parent ac2cf3d847
commit 775227f24c

View File

@ -71,7 +71,10 @@ bool Network::Select(int sock, struct timeval *tv)
sds.events = POLLIN; sds.events = POLLIN;
sds.revents = 0; sds.revents = 0;
v = net_poll(&sds, 1, tv->tv_sec * 1000 + tv->tv_usec / 1000); if (tv)
v = net_poll(&sds, 1, tv->tv_sec * 1000 + tv->tv_usec / 1000);
else
v = net_poll(&sds, 1, 0);
return v > 0; return v > 0;
} }
@ -87,11 +90,15 @@ void Network::InitNetwork()
{ {
char myIP[16]; char myIP[16];
memset(myIP, 0, sizeof(myIP));
Gui::gui->status_bar->queueMessage("Getting IP address via DHCP..."); Gui::gui->status_bar->queueMessage("Getting IP address via DHCP...");
/* Try twice */ /* Try twice */
if (if_config(myIP, NULL, NULL, true) < 0) { if (if_config(myIP, NULL, NULL, true) < 0) {
if (if_config(myIP, NULL, NULL, true) < 0) if (if_config(myIP, NULL, NULL, true) < 0)
{
Gui::gui->status_bar->queueMessage("No DHCP reply"); Gui::gui->status_bar->queueMessage("No DHCP reply");
return;
}
} }
Gui::gui->status_bar->queueMessage("Got an address"); Gui::gui->status_bar->queueMessage("Got an address");
} }