aboutsummaryrefslogtreecommitdiffstats
path: root/src/hci/commands/image_cmd.c
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2014-03-10 13:32:39 +0000
committerMichael Brown <mcb30@ipxe.org>2014-03-10 13:32:39 +0000
commit3f43c1354e1c1c537c1cae5ef6d0f75019b62174 (patch)
tree4b022f7e92433963a67a7e932b7e7c9dedccf12a /src/hci/commands/image_cmd.c
parentb850a6be2811e9c21d2f6c02ed6c94c51a6522a6 (diff)
downloadipxe-3f43c1354e1c1c537c1cae5ef6d0f75019b62174.tar.gz
[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>
Diffstat (limited to 'src/hci/commands/image_cmd.c')
-rw-r--r--src/hci/commands/image_cmd.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/hci/commands/image_cmd.c b/src/hci/commands/image_cmd.c
index dc30b3f24..a9e831bf5 100644
--- a/src/hci/commands/image_cmd.c
+++ b/src/hci/commands/image_cmd.c
@@ -40,6 +40,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
struct imgsingle_options {
/** Image name */
char *name;
+ /** Download timeout */
+ unsigned long timeout;
/** Replace image */
int replace;
/** Free image after execution */
@@ -49,13 +51,17 @@ struct imgsingle_options {
/** "img{single}" option list */
static union {
/* "imgexec" takes all three options */
- struct option_descriptor imgexec[3];
- /* Other "img{single}" commands take only --name and --autofree */
- struct option_descriptor imgsingle[2];
+ struct option_descriptor imgexec[4];
+ /* Other "img{single}" commands take only --name, --timeout,
+ * and --autofree
+ */
+ struct option_descriptor imgsingle[3];
} opts = {
.imgexec = {
OPTION_DESC ( "name", 'n', required_argument,
struct imgsingle_options, name, parse_string ),
+ OPTION_DESC ( "timeout", 't', required_argument,
+ struct imgsingle_options, timeout, parse_timeout),
OPTION_DESC ( "autofree", 'a', no_argument,
struct imgsingle_options, autofree, parse_flag ),
OPTION_DESC ( "replace", 'r', no_argument,
@@ -68,7 +74,8 @@ struct imgsingle_descriptor {
/** Command descriptor */
struct command_descriptor *cmd;
/** Function to use to acquire the image */
- int ( * acquire ) ( const char *name, struct image **image );
+ int ( * acquire ) ( const char *name, unsigned long timeout,
+ struct image **image );
/** Pre-action to take upon image, or NULL */
void ( * preaction ) ( struct image *image );
/** Action to take upon image, or NULL */
@@ -114,7 +121,8 @@ static int imgsingle_exec ( int argc, char **argv,
/* Acquire the image */
if ( name_uri ) {
- if ( ( rc = desc->acquire ( name_uri, &image ) ) != 0 )
+ if ( ( rc = desc->acquire ( name_uri, opts.timeout,
+ &image ) ) != 0 )
goto err_acquire;
} else {
image = image_find_selected();