Limit idle polling frequency
This commit is contained in:
parent
c3bf5267b0
commit
d1831ca48a
3 changed files with 12 additions and 1 deletions
|
@ -253,6 +253,7 @@ grub_ofnet_findcards (void)
|
|||
card->flags = 0;
|
||||
shortname = find_alias (alias->path);
|
||||
card->name = grub_xasprintf ("ofnet_%s", shortname ? : alias->path);
|
||||
card->idle_poll_delay_ms = 1;
|
||||
grub_free (shortname);
|
||||
|
||||
card->driver = &ofdriver;
|
||||
|
|
|
@ -768,6 +768,7 @@ receive_packets (struct grub_net_card *card)
|
|||
if (!nb)
|
||||
{
|
||||
grub_print_error ();
|
||||
card->last_poll = grub_get_time_ms ();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -775,6 +776,7 @@ receive_packets (struct grub_net_card *card)
|
|||
if (actual < 0)
|
||||
{
|
||||
grub_netbuff_free (nb);
|
||||
card->last_poll = grub_get_time_ms ();
|
||||
break;
|
||||
}
|
||||
grub_net_recv_ethernet_packet (nb, card);
|
||||
|
@ -800,7 +802,13 @@ grub_net_poll_cards_idle_real (void)
|
|||
{
|
||||
struct grub_net_card *card;
|
||||
FOR_NET_CARDS (card)
|
||||
receive_packets (card);
|
||||
{
|
||||
grub_uint64_t ctime = grub_get_time_ms ();
|
||||
|
||||
if (ctime < card->last_poll
|
||||
|| ctime >= card->last_poll + card->idle_poll_delay_ms)
|
||||
receive_packets (card);
|
||||
}
|
||||
}
|
||||
|
||||
/* Read from the packets list*/
|
||||
|
|
|
@ -95,6 +95,8 @@ struct grub_net_card
|
|||
grub_net_card_flags_t flags;
|
||||
int num_ifaces;
|
||||
int opened;
|
||||
unsigned idle_poll_delay_ms;
|
||||
grub_uint64_t last_poll;
|
||||
union
|
||||
{
|
||||
#ifdef GRUB_MACHINE_EFI
|
||||
|
|
Loading…
Reference in a new issue