• Nils Goroll's avatar
    Add a director release callback to let go of all backends · e8c77d89
    Nils Goroll authored
    Before this patch, layered directors needed to be destroyed top to
    bottom, and whenever that order was missed, we would panic, because a
    to-be-destroyed director still had references to it.
    
    One special case where this issue would always trigger are looped
    directors. Those should not be used and will cause havoc, which is a
    separate issue #3899. But we should still be able to unconfigure such
    a configuration.
    
    We solve the destruction order issue by making it a two step process:
    
    When a director is destroyed through VRT_DelDirector, a new release
    function is called, which has to disassociate any backends. The
    director then loses a reference, and when all references are gone, the
    destroy function is called.
    
    The new callback would not be necessary for the cases in varnish-cache
    today, directors could simply disassociate any backends before calling
    VRT_DelDirector. But this would complicate or even make impossible
    transfer of director ownership, where the code responsible for
    creating a director is not the same as the one calling
    VRT_DelDirector(). As a side effect, it also helps clarity.
    
    Fixes #3895
    e8c77d89
vmod_directors.h 2.39 KB