Limit idle polling frequency

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-07-06 18:21:07 +02:00
parent c3bf5267b0
commit d1831ca48a
3 changed files with 12 additions and 1 deletions

View file

@ -253,6 +253,7 @@ grub_ofnet_findcards (void)
card->flags = 0; card->flags = 0;
shortname = find_alias (alias->path); shortname = find_alias (alias->path);
card->name = grub_xasprintf ("ofnet_%s", shortname ? : alias->path); card->name = grub_xasprintf ("ofnet_%s", shortname ? : alias->path);
card->idle_poll_delay_ms = 1;
grub_free (shortname); grub_free (shortname);
card->driver = &ofdriver; card->driver = &ofdriver;

View file

@ -768,6 +768,7 @@ receive_packets (struct grub_net_card *card)
if (!nb) if (!nb)
{ {
grub_print_error (); grub_print_error ();
card->last_poll = grub_get_time_ms ();
return; return;
} }
@ -775,6 +776,7 @@ receive_packets (struct grub_net_card *card)
if (actual < 0) if (actual < 0)
{ {
grub_netbuff_free (nb); grub_netbuff_free (nb);
card->last_poll = grub_get_time_ms ();
break; break;
} }
grub_net_recv_ethernet_packet (nb, card); grub_net_recv_ethernet_packet (nb, card);
@ -800,7 +802,13 @@ grub_net_poll_cards_idle_real (void)
{ {
struct grub_net_card *card; struct grub_net_card *card;
FOR_NET_CARDS (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*/ /* Read from the packets list*/

View file

@ -95,6 +95,8 @@ struct grub_net_card
grub_net_card_flags_t flags; grub_net_card_flags_t flags;
int num_ifaces; int num_ifaces;
int opened; int opened;
unsigned idle_poll_delay_ms;
grub_uint64_t last_poll;
union union
{ {
#ifdef GRUB_MACHINE_EFI #ifdef GRUB_MACHINE_EFI