Commit 15cc069b authored by Nils Goroll's avatar Nils Goroll

bring back beresp.storage_hint for vcl 4.0

see doc/changes.rst for details

Closes #2509
parent 9305a2d4
......@@ -365,6 +365,53 @@ VRT_l_beresp_storage(VRT_CTX, VCL_STEVEDORE stv)
ctx->bo->storage = stv;
}
/*--------------------------------------------------------------------
* VCL <= 4.0 ONLY
*/
#include "storage/storage.h"
const char *
VRT_r_beresp_storage_hint(VRT_CTX)
{
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);
if (ctx->bo->storage == NULL)
return (NULL);
CHECK_OBJ_NOTNULL(ctx->bo->storage, STEVEDORE_MAGIC);
return (ctx->bo->storage->vclname);
}
void
VRT_l_beresp_storage_hint(VRT_CTX, const char *str, ...)
{
const char *p;
va_list ap;
uintptr_t sn;
VCL_STEVEDORE stv;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);
sn = WS_Snapshot(ctx->ws);
va_start(ap, str);
p = VRT_String(ctx->ws, NULL, str, ap);
va_end(ap);
if (p == NULL) {
VSLb(ctx->vsl, SLT_LostHeader, "storage_hint");
WS_MarkOverflow(ctx->ws);
WS_Reset(ctx->ws, sn);
return;
}
stv = VRT_stevedore(p);
if (stv != NULL)
ctx->bo->storage = stv;
WS_Reset(ctx->ws, sn);
}
/*--------------------------------------------------------------------*/
VCL_STEVEDORE
......
varnishtest "Stevedores RR, beresp.storage"
server s1 -repeat 6 {
server s1 -repeat 7 {
rxreq
txresp
} -start
......@@ -17,8 +17,11 @@ varnish v1 \
set beresp.storage = storage.s1;
} else if (bereq.url == "/6") {
set beresp.storage = vtc.no_stevedore();
} else if (bereq.url == "/deprecated") {
set beresp.storage_hint = "s1";
}
set beresp.http.storage = beresp.storage;
set beresp.http.storage-hint = beresp.storage_hint;
}
} -start
......@@ -26,19 +29,38 @@ client c1 {
txreq -url /1
rxresp
expect resp.http.storage == "storage.s1"
expect resp.http.storage == resp.http.storage-hint
txreq -url /2
rxresp
expect resp.http.storage == "storage.s1"
expect resp.http.storage == resp.http.storage-hint
txreq -url /3
rxresp
expect resp.http.storage == "storage.s0"
expect resp.http.storage == resp.http.storage-hint
txreq -url /4
rxresp
expect resp.http.storage == "storage.s1"
expect resp.http.storage == resp.http.storage-hint
txreq -url /5
rxresp
expect resp.http.storage == "storage.s2"
expect resp.http.storage == resp.http.storage-hint
txreq -url /6
rxresp
expect resp.http.storage == <undef>
expect resp.http.storage == resp.http.storage-hint
txreq -url /deprecated
rxresp
expect resp.http.storage == "storage.s1"
expect resp.http.storage == resp.http.storage-hint
} -run
varnish v1 \
-syntax 4.1 \
-errvcl "Only available when VCL syntax <= 4.0" {
import vtc;
sub vcl_backend_response {
set beresp.storage_hint = "foo";
}
}
......@@ -41,7 +41,17 @@ VCL and bundled VMODs
``req.hash_always_miss`` are now accessible from all of the client
side subs, not just ``vcl_recv{}``
* Removed ``beresp.storage_hint`` (was deprecated since Varnish 5.1)
* Removed ``beresp.storage_hint`` for VCL 4.1 (was deprecated since
Varnish 5.1)
For VCL 4.0, compatibility is preserved, but the implementation is
changed slightly: ``beresp.storage_hint`` is now referring to the
same internal data structure as ``beresp.storage``.
In particular, it was previously possible to set
``beresp.storage_hint`` to an invalid storage name and later
retrieve it back. Doing so will now yield the last successfully set
stevedore or the undefined (``NULL``) string.
* workspace overflows in ``std.log()`` now trigger a VCL failure
......
......@@ -868,6 +868,21 @@ beresp.storage
The storage backend to use to save this object.
beresp.storage_hint ``VCL <= 4.0``
Type: STRING
Readable from: vcl_backend_response, vcl_backend_error
Writable from: vcl_backend_response, vcl_backend_error
Deprecated since varnish 5.1 and discontinued since VCL
4.1 (varnish 6.0). Use beresp.storage instead.
Hint to Varnish that you want to save this object to a
particular storage backend.
obj
~~~
......
......@@ -61,8 +61,8 @@
* VRT_VSC_Overhead() added
* struct director.event added
* struct director.destroy added
* VRT_r_beresp_storage_hint() removed - under discussion #2509
* VRT_l_beresp_storage_hint() removed - under discussion #2509
* VRT_r_beresp_storage_hint() VCL <= 4.0 #2509
* VRT_l_beresp_storage_hint() VCL <= 4.0 #2509
* VRT_blob() added
* VCL_STRANDS added
* 6.1 (2017-09-15 aka 5.2)
......
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