Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
b072bb7e
Commit
b072bb7e
authored
May 15, 2019
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Copyediting
parent
f8f8f1f7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
17 deletions
+16
-17
vmod.rst
doc/sphinx/reference/vmod.rst
+16
-17
No files found.
doc/sphinx/reference/vmod.rst
View file @
b072bb7e
...
...
@@ -466,8 +466,9 @@ The VCL compiler supports the following private pointers:
* ``PRIV_CALL`` "per call" private pointers are useful to cache/store
state relative to the specific call or its arguments, for instance a
compiled regular expression specific to a regsub() statement or a
simply caching the last output of some expensive lookup.
compiled regular expression specific to a regsub() statement or
simply caching the most recent output of some expensive operation.
These private pointers live for the duration of the loaded VCL.
* ``PRIV_TASK`` "per task" private pointers are useful for state that
applies to calls for either a specific request or a backend
...
...
@@ -476,17 +477,21 @@ The VCL compiler supports the following private pointers:
for the client side and the backend side, so use in
``vcl_backend_*`` will yield a different private pointer from the
one used on the client side.
These private pointers live only for the duration of their task.
* ``PRIV_TOP`` "per top-request" private pointers live for the
duration of one request and all its ESI-includes. They are only
defined for the client side. When used from backend VCL subs, a NULL
pointer will be passed.
These private pointers live only for the duration of their top
level request
* ``PRIV_VCL`` "per vcl" private pointers are useful for such global
state that applies to all calls in this VCL, for instance flags that
determine if regular expressions are case-sensitive in this vmod or
similar. The ``PRIV_VCL`` object is the same object that is passed
to the VMOD's event function.
This private pointer lives for the duration of the loaded VCL.
The way it works in the vmod code, is that a ``struct vmod_priv *`` is
passed to the functions where one of the ``PRIV_*`` argument types is
...
...
@@ -501,22 +506,16 @@ This structure contains three members::
vmod_priv_free_f *free;
};
The "priv" element can be used for whatever the vmod code wants to
use it for, it defaults to a NULL pointer.
The "priv" and "len" elements can be used for whatever the vmod
code wants to use them for, and the "free" element provides a
callback to clean them up.
The "len" element is used primarily for BLOBs to indicate its size.
The "free" element defaults to NULL, and it is the modules responsibility
to set it to a suitable function, which can clean up whatever the "priv"
pointer points to.
When a VCL program is discarded, all private pointers are checked
to see if both the "priv" and "free" elements are non-NULL, and if
they are, the "free" function will be called with the "priv" pointer
as the only argument.
If both the "priv" and "free" pointers are non-NULL when the scope
ends, the "free" function will be called with the "priv" pointer
as its only argument.
In the common case where a private data structure is allocated with
malloc would look like this::
malloc
(3)
would look like this::
if (priv->priv == NULL) {
priv->priv = calloc(1, sizeof(struct myfoo));
...
...
@@ -532,10 +531,10 @@ malloc would look like this::
...
}
The per-call vmod_privs are freed before the per-vcl vmod_priv.
Note on use with objects:
The per-call vmod_privs are freed before the per-vcl vmod_priv.
``PRIV_TASK`` and ``PRIV_TOP`` arguments are not per object instance,
but still per vmod as for ordinary vmod functions. Thus, vmods
requiring per-task / per top-request state for object instances need
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment