Commit 3a8ab1ed authored by Nils Goroll's avatar Nils Goroll

rework the vmod interface for setting flags

parent 12fa49fa
......@@ -65,26 +65,31 @@ missing error handling in varnish-cache. Notice that the VMOD has no
known way to check for this condition, so please address any blame
appropriately.
.. _vmod_pesi.serial:
.. _vmod_pesi.set:
VOID serial(BOOL serial=0)
--------------------------
VOID set(ENUM {serial} parameter, [BOOL bool])
----------------------------------------------
Activates serial mode if the argument is ``true``.
To be called from ``vcl_deliver {}`` only.
To be called from vcl_deliver {} only, the default argument is
``false``.
Set per (sub)request parameters for pesi which are documented
below. Parameters may require one or more of the other additional
arguments as documented below. Failure to provide them triggers a VCL
error.
In serial mode, no new threads will be started from this request and
all ESI subrequests at the next level only will be processed by the
current thread.
* ``serial``, requires *bool* argument
In other words, the setting only affects include processing for the
current response body.
Activates serial mode if *bool* is ``true``.
It is strongly recommended to _not_ use serial mode from ESI level 0
because the ESI level 0 thread is responsible for sending available
data to the client.
In serial mode, no new threads will be started from this request, so
all ESI subrequests at the next level will be processed by the
current thread. In other words, the setting only affects include
processing for the current response body.
It is strongly recommended to _not_ use serial mode from ESI level 0
because the ESI level 0 thread is responsible for sending available
data to the client and thus should be running concurrently to other
parallel ESI threads.
.. _vmod_pesi.version:
......
......@@ -9,6 +9,7 @@ vmod_LTLIBRARIES = libvmod_pesi.la
libvmod_pesi_la_SOURCES = \
vdp_pesi.c \
tbl_set_parameter.h \
foreign/qdef.h \
foreign/from_cache_esi_deliver.h \
foreign/from_cache_esi_deliver.c
......
VMODENUM(serial, PF_CFG_SERIAL)
#undef VMODENUM
......@@ -49,7 +49,7 @@ varnish v1 -arg "-p debug=+syncvsl" -vcl+backend {
sub vcl_deliver {
pesi.activate();
pesi.serial(true);
pesi.set(serial, true);
}
} -start
......@@ -264,7 +264,7 @@ varnish v1 -vcl+backend {
sub vcl_deliver {
pesi.activate();
if (std.integer(req.http.Serial-Level, -1) >= req.esi_level) {
pesi.serial(true);
pesi.set(serial, true);
}
}
}
......
......@@ -2966,20 +2966,37 @@ vmod_activate(VRT_CTX)
req->filter_list = filters;
}
static unsigned
vmod_set_param_flag(VCL_ENUM e)
{
#define VMODENUM(p,f) if (e == VENUM(p)) return(f);
#include "tbl_set_parameter.h"
WRONG("illegal enum");
}
VCL_VOID
vmod_serial(VRT_CTX, VCL_BOOL b)
vmod_set(VRT_CTX, struct VARGS(set) *args)
{
struct vmod_priv *priv_task;
unsigned vclflags;
unsigned f, vclflags;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
if (ctx->method != VCL_MET_DELIVER) {
VRT_fail(ctx, "pesi.serial() may only be called "
VRT_fail(ctx, "pesi.set() may only be called "
"from vcl_deliver{}");
return;
}
/* as of now, all parameters require a bool parameter */
if (args->valid_bool == 0) {
VRT_fail(ctx, "pesi.set(%s) requires a bool "
"parameter", args->parameter);
return;
}
/* get current flags from priv_task */
priv_task = VRT_priv_task(ctx, priv_task_id_cfg);
if (priv_task == NULL) {
......@@ -2998,11 +3015,15 @@ vmod_serial(VRT_CTX, VCL_BOOL b)
assert(priv_task->len == 1);
}
AZ(vclflags & ~PF_MASK_CFG);
/* set by args */
vclflags &= ~PF_CFG_SERIAL;
if (b)
vclflags |= PF_CFG_SERIAL;
f = vmod_set_param_flag(args->parameter);
vclflags &= ~f;
if (args->bool)
vclflags |= f;
AZ(vclflags & ~PF_MASK_CFG);
priv_task->priv = (void *)(uintptr_t)vclflags;
}
......
......@@ -54,23 +54,28 @@ missing error handling in varnish-cache. Notice that the VMOD has no
known way to check for this condition, so please address any blame
appropriately.
$Function VOID serial(BOOL serial=0)
$Function VOID set(ENUM { serial } parameter, [BOOL bool])
Activates serial mode if the argument is ``true``.
To be called from ``vcl_deliver {}`` only.
To be called from vcl_deliver {} only, the default argument is
``false``.
Set per (sub)request parameters for pesi which are documented
below. Parameters may require one or more of the other additional
arguments as documented below. Failure to provide them triggers a VCL
error.
In serial mode, no new threads will be started from this request and
all ESI subrequests at the next level only will be processed by the
current thread.
* ``serial``, requires *bool* argument
In other words, the setting only affects include processing for the
current response body.
Activates serial mode if *bool* is ``true``.
It is strongly recommended to _not_ use serial mode from ESI level 0
because the ESI level 0 thread is responsible for sending available
data to the client.
In serial mode, no new threads will be started from this request, so
all ESI subrequests at the next level will be processed by the
current thread. In other words, the setting only affects include
processing for the current response body.
It is strongly recommended to _not_ use serial mode from ESI level 0
because the ESI level 0 thread is responsible for sending available
data to the client and thus should be running concurrently to other
parallel ESI threads.
$Function STRING version()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment