Stop polling as soon as we have the packet we were waiting for.

* include/grub/net.h (grub_net_poll_cards): New argument stop_condition.
	All users updated.
	* grub-core/net/arp.c (have_pending): New var.
	(pending_req): Likewise.
	(grub_net_arp_send_request): Fill pending_req and use have_pending as
	stop indicator.
	(grub_net_arp_receive): Set have_pending.
	* grub-core/net/dns.c (recv_data): New field stop.
	(recv_hook): Set stop.
	(grub_net_dns_lookup): Init stop and use as stop condition.
	* grub-core/net/http.c (http_establish): Use headers_recv as stop
	condition.
	* grub-core/net/net.c (grub_net_poll_cards): New argument
	stop_condition. Stop when it goes true.
	* grub-core/net/tcp.c (grub_net_tcp_open): Use `established' as stop
	indicator.
	* grub-core/net/tftp.c (tftp_open): Use `have_oack' as stop indicator.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2012-06-09 11:06:55 +02:00
parent 3e74723951
commit 96f7e60eae
10 changed files with 48 additions and 18 deletions

View file

@ -45,6 +45,8 @@ struct arphdr {
grub_uint16_t op;
} __attribute__ ((packed));
static int have_pending;
static grub_uint32_t pending_req;
grub_err_t
grub_net_arp_send_request (struct grub_net_network_level_interface *inf,
@ -106,7 +108,9 @@ grub_net_arp_send_request (struct grub_net_network_level_interface *inf,
{
if (grub_net_link_layer_resolve_check (inf, proto_addr))
return GRUB_ERR_NONE;
grub_net_poll_cards (GRUB_NET_INTERVAL);
pending_req = proto_addr->ipv4;
have_pending = 0;
grub_net_poll_cards (GRUB_NET_INTERVAL, &have_pending);
if (grub_net_link_layer_resolve_check (inf, proto_addr))
return GRUB_ERR_NONE;
nb.data = nbd;
@ -140,6 +144,8 @@ grub_net_arp_receive (struct grub_net_buff *nb,
target_addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
grub_memcpy (&sender_addr.ipv4, sender_protocol_address, 4);
grub_memcpy (&target_addr.ipv4, target_protocol_address, 4);
if (grub_memcmp (sender_protocol_address, &pending_req, 4) == 0)
have_pending = 1;
}
else
return GRUB_ERR_NONE;