Implement flow control for tftp.
* grub-core/net/net.c (receive_packets): Decrease the stop to 10 packets but stop only if stop condition is satisfied. (grub_net_fs_read_real): Call packets_pulled after real read. Use `stall' instead of `eof' as stop condition. * grub-core/net/http.c (parse_line): Set `stall' on EOF. (http_err): Likewise. * grub-core/net/tftp.c (ack): Replace the first argument with data instead of socket. (tftp_receive): Stall if too many packets are in wait queue. (tftp_packets_pulled): New function. (grub_tftp_protocol): Set packets_pulled. * include/grub/net.h (grub_net_packets): New field count. (grub_net_put_packet): Increment count. (grub_net_remove_packet): Likewise. (grub_net_app_protocol): New field `packets_pulled'. (grub_net): New field `stall'.
This commit is contained in:
parent
6b9cfac683
commit
b27069e06d
5 changed files with 78 additions and 14 deletions
|
@ -1309,7 +1309,7 @@ grub_net_fs_close (grub_file_t file)
|
|||
}
|
||||
|
||||
static void
|
||||
receive_packets (struct grub_net_card *card)
|
||||
receive_packets (struct grub_net_card *card, int *stop_condition)
|
||||
{
|
||||
int received = 0;
|
||||
if (card->num_ifaces == 0)
|
||||
|
@ -1332,7 +1332,7 @@ receive_packets (struct grub_net_card *card)
|
|||
and just mark them as used and not used. */
|
||||
struct grub_net_buff *nb;
|
||||
|
||||
if (received > 100)
|
||||
if (received > 10 && stop_condition && *stop_condition)
|
||||
break;
|
||||
|
||||
nb = card->driver->recv (card);
|
||||
|
@ -1362,7 +1362,7 @@ grub_net_poll_cards (unsigned time, int *stop_condition)
|
|||
while ((grub_get_time_ms () - start_time) < time
|
||||
&& (!stop_condition || !*stop_condition))
|
||||
FOR_NET_CARDS (card)
|
||||
receive_packets (card);
|
||||
receive_packets (card, stop_condition);
|
||||
grub_net_tcp_retransmit ();
|
||||
}
|
||||
|
||||
|
@ -1376,7 +1376,7 @@ grub_net_poll_cards_idle_real (void)
|
|||
|
||||
if (ctime < card->last_poll
|
||||
|| ctime >= card->last_poll + card->idle_poll_delay_ms)
|
||||
receive_packets (card);
|
||||
receive_packets (card, 0);
|
||||
}
|
||||
grub_net_tcp_retransmit ();
|
||||
}
|
||||
|
@ -1417,12 +1417,19 @@ grub_net_fs_read_real (grub_file_t file, char *buf, grub_size_t len)
|
|||
nb->data += amount;
|
||||
|
||||
if (!len)
|
||||
return total;
|
||||
{
|
||||
if (net->protocol->packets_pulled)
|
||||
net->protocol->packets_pulled (file);
|
||||
return total;
|
||||
}
|
||||
}
|
||||
if (net->protocol->packets_pulled)
|
||||
net->protocol->packets_pulled (file);
|
||||
|
||||
if (!net->eof)
|
||||
{
|
||||
try++;
|
||||
grub_net_poll_cards (GRUB_NET_INTERVAL, &net->eof);
|
||||
grub_net_poll_cards (GRUB_NET_INTERVAL, &net->stall);
|
||||
}
|
||||
else
|
||||
return total;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue