diff mbox series

discover/device-handler: Restore autoboot setting on requery

Message ID 20180827015047.24676-1-sam@mendozajonas.com
State Accepted
Headers show
Series discover/device-handler: Restore autoboot setting on requery | expand

Commit Message

Sam Mendoza-Jonas Aug. 27, 2018, 1:50 a.m. UTC
When a device requery is triggered we cancel any default boot option on
the device. This also disables autoboot which we don't want; any boot
options found after the requery will not be able to autoboot.
To avoid this restore the existing autoboot setting after checking for
default options.

This prevents a particular corner case where a default boot option has
been selected for boot but one of its boot files has stalled or is
taking more time to download than the requery timeout and the requery
accidentally cancels autoboot preventing Petitboot from trying to boot
again.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
---
 discover/device-handler.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Sam Mendoza-Jonas Aug. 28, 2018, 7:02 a.m. UTC | #1
On Mon, 2018-08-27 at 11:50 +1000, Samuel Mendoza-Jonas wrote:
> When a device requery is triggered we cancel any default boot option on
> the device. This also disables autoboot which we don't want; any boot
> options found after the requery will not be able to autoboot.
> To avoid this restore the existing autoboot setting after checking for
> default options.
> 
> This prevents a particular corner case where a default boot option has
> been selected for boot but one of its boot files has stalled or is
> taking more time to download than the requery timeout and the requery
> accidentally cancels autoboot preventing Petitboot from trying to boot
> again.
> 
> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
> ---
>  discover/device-handler.c | 8 ++++++++
>  1 file changed, 8 insertions(+)

Merged as 3917e88b

> 
> diff --git a/discover/device-handler.c b/discover/device-handler.c
> index cf379e78..34437d66 100644
> --- a/discover/device-handler.c
> +++ b/discover/device-handler.c
> @@ -1278,6 +1278,7 @@ static int device_handler_requery_timeout_fn(void *data)
>  	struct requery_data *rqd = data;
>  	struct device_handler *handler;
>  	struct discover_device *device;
> +	bool autoboot;
>  
>  	handler = rqd->handler;
>  	device = rqd->device;
> @@ -1300,6 +1301,11 @@ static int device_handler_requery_timeout_fn(void *data)
>  		talloc_free(opt);
>  	}
>  
> +	/* Track whether autoboot was enabled, if we cancel a default option
> +	 * it will be switched off.
> +	 */
> +	autoboot = handler->autoboot_enabled;
> +
>  	list_for_each_entry_safe(&device->boot_options, opt, tmp, list) {
>  		if (opt == handler->default_boot_option) {
>  			pb_log("Default option %s cancelled since device is being requeried",
> @@ -1310,6 +1316,8 @@ static int device_handler_requery_timeout_fn(void *data)
>  		talloc_free(opt);
>  	}
>  
> +	handler->autoboot_enabled = autoboot;
> +
>  	discover_server_notify_device_remove(handler->server, device->device);
>  	device->notified = false;
>
diff mbox series

Patch

diff --git a/discover/device-handler.c b/discover/device-handler.c
index cf379e78..34437d66 100644
--- a/discover/device-handler.c
+++ b/discover/device-handler.c
@@ -1278,6 +1278,7 @@  static int device_handler_requery_timeout_fn(void *data)
 	struct requery_data *rqd = data;
 	struct device_handler *handler;
 	struct discover_device *device;
+	bool autoboot;
 
 	handler = rqd->handler;
 	device = rqd->device;
@@ -1300,6 +1301,11 @@  static int device_handler_requery_timeout_fn(void *data)
 		talloc_free(opt);
 	}
 
+	/* Track whether autoboot was enabled, if we cancel a default option
+	 * it will be switched off.
+	 */
+	autoboot = handler->autoboot_enabled;
+
 	list_for_each_entry_safe(&device->boot_options, opt, tmp, list) {
 		if (opt == handler->default_boot_option) {
 			pb_log("Default option %s cancelled since device is being requeried",
@@ -1310,6 +1316,8 @@  static int device_handler_requery_timeout_fn(void *data)
 		talloc_free(opt);
 	}
 
+	handler->autoboot_enabled = autoboot;
+
 	discover_server_notify_device_remove(handler->server, device->device);
 	device->notified = false;