[RFC PATCH] discover/pxe-parser: Retrieve configs asynchronously

Jeremy Kerr jk at ozlabs.org
Mon Jun 13 18:47:01 AEST 2016

Hi Sam,

> +	/*
> +	 * Retrieving PXE configs over the network can take some time depending
> +	 * on factors such as slow network, malformed paths, bad DNS, and
> +	 * overzealous firewalls. Instead of blocking the discover server while
> +	 * we wait for these, spawn an asynchronous job for each URL we can
> +	 * parse and process the resulting files in a callback.
> +	 * Since the caller will free the discover_context once
> +	 * iterate_parsers() completes, we need to copy the discover_context
> +	 * under a different talloc context so that it survives until the
> +	 * callback it finished with it.
> +	 */

This sounds a little dangerous - there may be other allocations made
under the original discover_context that get freed after
iterate_parsers() returns there.

Can we either:

 - have this code create a second reference to the talloc-ed
   discover_context, so that it doesn't get freed until both references
   have finished using the context (which may require checking that
   talloc_ref and friends work the way we assume), or

 - rethink the lifetime of the contexts, so that we only free once we
   know that the context is unused.



More information about the Petitboot mailing list