[RFC PATCH] discover/pxe-parser: Retrieve configs asynchronously
sam at mendozajonas.com
Tue Jun 14 11:00:44 AEST 2016
On Mon, Jun 13, 2016 at 06:47:01PM +1000, Jeremy Kerr wrote:
> 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.
Yeah it certainly blew up a few times before it was ready :) I've sanity
checked the lifetimes of what happens with each discover context to the
point that I'm fairly happy with it - but it still leaves it a bit
vulnerable to future changes.
> 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
I like this, sounds it should be fairly straightforward with
talloc_reference and talloc_free/talloc_unlink, I'll give it a shot.
> - rethink the lifetime of the contexts, so that we only free once we
> know that the context is unused.
More information about the Petitboot