New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make it possible to call VCL_vcl_rel() during object finalization #2471
Comments
The problem here is that the MGT process manages the VCL refcounts (too). We can only allow a VCL(+ its vmods) to rel/ref VCL's VCC knew about and alerted MGT to. |
For VCL references held by VMODs, there is See 50aeefc for the patch, then 50aeefc and 502a871 for the test case. This doesn't solve the null VRT_CTX problem, but this is the API that doesn't mess with the MGT. |
I'm timing this ticket out. If the issue is still relevant, at the very least provide a real-world example why it would be necessary for VMODs to hold on to other VCLs than their own. |
@bsdphk the use case is documented here for long: 50aeefc#diff-28a38e034a15459ccc462fba6c3db5c1R386 Other than that, I think that having a CTX in object finalizes will have other benefits (for example, how would one log from a finalizer without a msg/vsl pointer?) Regarding references to VCLs, I think that an alternative would be to wait for background tasks to finish in a destructor, but I could imagine this would create all kinds of vicious circles (e.g. if a backend needs a background task, which only finishes after its references are gone, without any extra complications we would immediately run into a dead lock) |
their VCL from going cold. One half of #2471
bugwash: will see how the new api looks in practice, then close. |
@bsdphk Reviewing your change 43da3e4, I do not understand your intention. refcounting via
|
Also, the original issue is not addressed: |
Regarding the actual implementation, trying it here nigoroll/libvmod-dynamic@bd94be6 revealed the problem that the temperature lock is being held during VCL Events, so
|
the child process. Inspired by: varnishcache#2471
their VCL from going cold. One half of varnishcache#2471
cold&discard for their VCL. Closes: varnishcache#2471
the child process. Inspired by: varnishcache#2471
the child process. Inspired by: varnishcache#2471
At the request of @bsdphk I'm posting this here as a reminder after a conversation on #varnish-hacking.
VCL_vcl_rel(VRT_CTX, VCL_VCL)
requires the VRT_CTX argument, but no VRT_CTX argument is available in an object finalizer. So it can't be used (without some trickery) by a VMOD object that holds references to VCLs.The implementation of
VCL_vcl_rel
actually doesn't use the ctx argument, other than callingCHECK_OBJ_NOTNULL
on it. Decrementing the refcount on the VCL only depends on the VCL object, not on the ctx.This is used here: https://code.uplex.de/uplex-varnish/libvmod-dispatch
And the call can actually be done in the object finalizer with this:
And then passing in
&dummy_ctx
in the VRT_CTX position. That satisfiesCHECK_OBJ_NOTNULL
, and then the VCL deref gets executed correctly, but of course it is quite hackish.The options appear to be:
VCL_vcl_rel
The text was updated successfully, but these errors were encountered: