]> git.ozlabs.org Git - petitboot/commit
discover: don't free cancelled load tasks
authorJeremy Kerr <jk@ozlabs.org>
Thu, 22 May 2014 10:42:33 +0000 (18:42 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Thu, 22 May 2014 12:54:53 +0000 (20:54 +0800)
commit1d69ceee0b8fac1f4451a75b6e4b14ee2d5d91dc
tree47ce4e027f3a1b73b04391a3e34dd23f2ac67b07
parent1ae17ad22c1d111e35d75d4e93d609efd61b5329
discover: don't free cancelled load tasks

Currently, we have a bug when a boot task with more than one load tasks
is cancelled:

1) boot_cancel calls cleanup_cancellations, which performs a
load_url_async_cancel on all load tasks. This sets the load tasks'
states to LOAD_CANCELLED, and signals associated processes.

2) The first load task process completes, we get a load_url_process_exit
callback. This then invokes cleanup_cancellations.

3) cleanup_cancellations then (incorrectly) frees the boot task (and
hence freeing all pending load tasks) as no load tasks are in LOAD_ASYNC
state (we set them all to LOAD_CANCELLED in step 1)

4) The actual completion for the second load task attempts to reference
the now-freed task structure.

This change fixes the issue by handing the LOAD_CANCELLED state properly
- if we find a load task in this state, we consider the boot task still
pending, and delay the free until all loads are complete.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
discover/boot.c