[image] Add "--timeout" parameter to image downloading commands

iPXE will detect timeout failures in several situations: network
link-up, DHCP, TCP connection attempts, unacknowledged TCP data, etc.
This does not cover all possible circumstances.  For example, if a
connection to a web server is successfully established and the web
server acknowledges the HTTP request but never sends any data in
response, then no timeout will be triggered.  There is no timeout
defined within the HTTP specifications, and the underlying TCP
connection will not generate a timeout since it has no way to know
that the HTTP layer is expecting to receive data from the server.

Add a "--timeout" parameter to "imgfetch", "chain", etc.  If no
progress is made (i.e. no data is downloaded) within the timeout
period, then the download will be aborted.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2014-03-10 13:32:39 +00:00
parent b850a6be28
commit 3f43c1354e
8 changed files with 44 additions and 21 deletions

View File

@@ -86,6 +86,8 @@ struct imgverify_options {
char *signer;
/** Keep signature after verification */
int keep;
/** Download timeout */
unsigned long timeout;
};
/** "imgverify" option list */
@@ -94,6 +96,8 @@ static struct option_descriptor imgverify_opts[] = {
struct imgverify_options, signer, parse_string ),
OPTION_DESC ( "keep", 'k', no_argument,
struct imgverify_options, keep, parse_flag ),
OPTION_DESC ( "timeout", 't', required_argument,
struct imgverify_options, timeout, parse_timeout),
};
/** "imgverify" command descriptor */
@@ -127,11 +131,12 @@ static int imgverify_exec ( int argc, char **argv ) {
signature_name_uri = argv[ optind + 1 ];
/* Acquire the image */
if ( ( rc = imgacquire ( image_name_uri, &image ) ) != 0 )
if ( ( rc = imgacquire ( image_name_uri, opts.timeout, &image ) ) != 0 )
goto err_acquire_image;
/* Acquire the signature image */
if ( ( rc = imgacquire ( signature_name_uri, &signature ) ) != 0 )
if ( ( rc = imgacquire ( signature_name_uri, opts.timeout,
&signature ) ) != 0 )
goto err_acquire_signature;
/* Verify image */