summaryrefslogtreecommitdiffstats
path: root/src/usr
diff options
context:
space:
mode:
authorMichael Brown2014-03-10 14:32:39 +0100
committerMichael Brown2014-03-10 14:32:39 +0100
commit3f43c1354e1c1c537c1cae5ef6d0f75019b62174 (patch)
tree4b022f7e92433963a67a7e932b7e7c9dedccf12a /src/usr
parent[monojob] Reset timeout when progress is made (diff)
downloadipxe-3f43c1354e1c1c537c1cae5ef6d0f75019b62174.tar.gz
ipxe-3f43c1354e1c1c537c1cae5ef6d0f75019b62174.tar.xz
ipxe-3f43c1354e1c1c537c1cae5ef6d0f75019b62174.zip
[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/usr')
-rw-r--r--src/usr/autoboot.c2
-rw-r--r--src/usr/imgmgmt.c18
2 files changed, 13 insertions, 7 deletions
diff --git a/src/usr/autoboot.c b/src/usr/autoboot.c
index c9012f21..af3d1f7b 100644
--- a/src/usr/autoboot.c
+++ b/src/usr/autoboot.c
@@ -165,7 +165,7 @@ int uriboot ( struct uri *filename, struct uri *root_path, int drive,
/* Attempt filename boot if applicable */
if ( filename ) {
- if ( ( rc = imgdownload ( filename, &image ) ) != 0 )
+ if ( ( rc = imgdownload ( filename, 0, &image ) ) != 0 )
goto err_download;
image->flags |= IMAGE_AUTO_UNREGISTER;
if ( ( rc = image_exec ( image ) ) != 0 ) {
diff --git a/src/usr/imgmgmt.c b/src/usr/imgmgmt.c
index 18cabbbc..c9c57164 100644
--- a/src/usr/imgmgmt.c
+++ b/src/usr/imgmgmt.c
@@ -40,10 +40,12 @@ FILE_LICENCE ( GPL2_OR_LATER );
* Download a new image
*
* @v uri URI
+ * @v timeout Download timeout
* @v image Image to fill in
* @ret rc Return status code
*/
-int imgdownload ( struct uri *uri, struct image **image ) {
+int imgdownload ( struct uri *uri, unsigned long timeout,
+ struct image **image ) {
const char *password;
char *uri_string_redacted;
int rc;
@@ -80,7 +82,7 @@ int imgdownload ( struct uri *uri, struct image **image ) {
}
/* Wait for download to complete */
- if ( ( rc = monojob_wait ( uri_string_redacted, 0 ) ) != 0 )
+ if ( ( rc = monojob_wait ( uri_string_redacted, timeout ) ) != 0 )
goto err_monojob_wait;
/* Register image */
@@ -105,17 +107,19 @@ int imgdownload ( struct uri *uri, struct image **image ) {
* Download a new image
*
* @v uri_string URI string
+ * @v timeout Download timeout
* @v image Image to fill in
* @ret rc Return status code
*/
-int imgdownload_string ( const char *uri_string, struct image **image ) {
+int imgdownload_string ( const char *uri_string, unsigned long timeout,
+ struct image **image ) {
struct uri *uri;
int rc;
if ( ! ( uri = parse_uri ( uri_string ) ) )
return -ENOMEM;
- rc = imgdownload ( uri, image );
+ rc = imgdownload ( uri, timeout, image );
uri_put ( uri );
return rc;
@@ -125,10 +129,12 @@ int imgdownload_string ( const char *uri_string, struct image **image ) {
* Acquire an image
*
* @v name_uri Name or URI string
+ * @v timeout Download timeout
* @v image Image to fill in
* @ret rc Return status code
*/
-int imgacquire ( const char *name_uri, struct image **image ) {
+int imgacquire ( const char *name_uri, unsigned long timeout,
+ struct image **image ) {
/* If we already have an image with the specified name, use it */
*image = find_image ( name_uri );
@@ -136,7 +142,7 @@ int imgacquire ( const char *name_uri, struct image **image ) {
return 0;
/* Otherwise, download a new image */
- return imgdownload_string ( name_uri, image );
+ return imgdownload_string ( name_uri, timeout, image );
}
/**