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:
parent
3e74723951
commit
96f7e60eae
10 changed files with 48 additions and 18 deletions
|
@ -339,7 +339,7 @@ grub_cmd_ipv6_autoconf (struct grub_command *cmd __attribute__ ((unused)),
|
|||
}
|
||||
if (done)
|
||||
break;
|
||||
grub_net_poll_cards (interval);
|
||||
grub_net_poll_cards (interval, 0);
|
||||
}
|
||||
|
||||
err = GRUB_ERR_NONE;
|
||||
|
@ -1336,16 +1336,15 @@ receive_packets (struct grub_net_card *card)
|
|||
}
|
||||
|
||||
void
|
||||
grub_net_poll_cards (unsigned time)
|
||||
grub_net_poll_cards (unsigned time, int *stop_condition)
|
||||
{
|
||||
struct grub_net_card *card;
|
||||
grub_uint64_t start_time;
|
||||
FOR_NET_CARDS (card)
|
||||
{
|
||||
start_time = grub_get_time_ms ();
|
||||
while ((grub_get_time_ms () - start_time) < time)
|
||||
receive_packets (card);
|
||||
}
|
||||
start_time = grub_get_time_ms ();
|
||||
while ((grub_get_time_ms () - start_time) < time
|
||||
&& (!stop_condition || !*stop_condition))
|
||||
FOR_NET_CARDS (card)
|
||||
receive_packets (card);
|
||||
grub_net_tcp_retransmit ();
|
||||
}
|
||||
|
||||
|
@ -1405,7 +1404,7 @@ grub_net_fs_read_real (grub_file_t file, char *buf, grub_size_t len)
|
|||
if (!net->eof)
|
||||
{
|
||||
try++;
|
||||
grub_net_poll_cards (GRUB_NET_INTERVAL);
|
||||
grub_net_poll_cards (GRUB_NET_INTERVAL, &net->eof);
|
||||
}
|
||||
else
|
||||
return total;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue