]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[script] Allow scripts to be replaced
authorMichael Brown <mcb30@ipxe.org>
Wed, 9 Mar 2011 17:32:32 +0000 (17:32 +0000)
committerMichael Brown <mcb30@ipxe.org>
Wed, 9 Mar 2011 17:32:32 +0000 (17:32 +0000)
A script that downloads a new image using imgdownload() with the
action register_and_replace_image() can now be freed immediately
before the replacement image is executed.  This functionality is not
yet exposed via an iPXE command.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/image/script.c

index 9749b0972b0eb02c878c396a43d9671e5919fff8..161ac682e7cc650cabd80261910d2ebbe6ff52b9 100644 (file)
@@ -148,9 +148,13 @@ static int script_exec ( struct image *image ) {
        rc = process_script ( image, script_exec_line,
                              terminate_on_exit_or_failure );
 
-       /* Restore saved state, re-register image, and return */
+       /* Restore saved state */
        script_offset = saved_offset;
-       register_image ( image );
+
+       /* Re-register image (unless we have been replaced) */
+       if ( ! image->replacement )
+               register_image ( image );
+
        return rc;
 }