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:
Vladimir 'phcoder' Serbinenko 2012-06-22 14:17:46 +02:00
parent 6b9cfac683
commit b27069e06d
5 changed files with 78 additions and 14 deletions

View file

@ -82,6 +82,7 @@ parse_line (grub_file_t file, http_data_t data, char *ptr, grub_size_t len)
if (data->chunk_rem == 0)
{
file->device->net->eof = 1;
file->device->net->stall = 1;
if (file->size == GRUB_FILE_SIZE_UNKNOWN)
file->size = have_ahead (file);
}
@ -156,6 +157,7 @@ http_err (grub_net_tcp_socket_t sock __attribute__ ((unused)),
grub_free (data->current_line);
grub_free (data);
file->device->net->eof = 1;
file->device->net->stall = 1;
if (file->size == GRUB_FILE_SIZE_UNKNOWN)
file->size = have_ahead (file);
}