Ideally, I'd like to do something like this:
sub vcl_after_response_is_sent {
mymod.f(req, resp);
}
But I don't see any builtin subroutine that could let you do this. Is there any other way it might be accomplished?
This can be done using PRIV_TASK with a free function.
In the module's VCC declare the function as follows:
$Function VOID f(PRIV_TASK)
Use something like the following for the function's definition:
void finish_request(void*) {
}
VCL_VOID vmod_trace_request(VRT_CTX, struct vmod_priv* priv_task) {
priv_task->priv = /* Some non-null value */
priv_task->free = finish_request;
}
If f
is then called from vcl_recv
sub vcl_recv {
mymod.f();
}
finish_request
will be invoked when varnish is done with the request.