• Nils Goroll's avatar
    Call VRT_priv_{task,top} for each PRIV_{TASK,TOP} argument · 7d06b8b9
    Nils Goroll authored
    to avoid using stale pointers after a rollback.
    
    Before this change, we would call VRT_priv_* only once per subroutine,
    which can be *) a nice performance optimization, but leaves us with stale
    pointers after a rollback.
    
    Rather than adding complications for the rollback case just to keep the
    option of the "per subroutine pointer cache", just retrieve a fresh
    priv pointer every time.
    
    The other use of the per subroutine initialization was error handling,
    which needs additional code outside the function arguments, simply
    because a return statement is not possible within function arguments. We
    removed the requirement for error handling in the previous commit by
    making sure that VRT_priv_{task,top} always return a valid pointer.
    
    Fixes https://github.com/varnish/varnish-modules/issues/222
    
    Alternative implementation to #4060
    
    *) It is not an optimization in all cases, for example the priv pointers
       were intialized unconditionally, even if code using them was not
       reached - but then again, this is something C compilers might
       optimize...
    7d06b8b9