Commit 3e00cac5 authored by Geoff Simmons's avatar Geoff Simmons

In Varnish 5.0, hash() is legal in vcl_init and _fini

parent 2036307d
Pipeline #71 skipped
......@@ -480,8 +480,9 @@ Example::
REQUIREMENTS
============
This VMOD requires at least Varnish version 4.1, and has been tested
against versions through 5.0.0.
This version of the VMOD requires Varnish version 5.0.0. See branch
4.1 in the source repository for versions that are compatible with
Varnish 4.1.
The gcc compiler and Perl 5 are required for the build. For the
self-tests invoked by ``make check``, the VMODs ``blobcode`` and
......
......@@ -608,3 +608,43 @@ logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" {
expect * = VCL_Error "^vmod blobdigest error: already finalized in d1.update..$"
expect * = End
} -run
# hash() is legal in vcl_init and vcl_fini (as of Varnish 5.0)
varnish v2 -arg "-p debug=+vclrel" -vcl {
import blobdigest from "${vmod_topbuild}/src/.libs/libvmod_blobdigest.so";
import blobcode;
import blob;
import std;
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new empty = blobcode.blob(IDENTITY, "");
new md5 = blobcode.blob(HEX,
"D41D8CD98F00B204E9800998ECF8427E");
if (!blob.equal(blobdigest.hash(MD5, empty.get()), md5.get())) {
return(fail);
}
}
sub vcl_fini {
if (blob.equal(blobdigest.hash(MD5, empty.get()), md5.get())) {
std.log("blobs are equal");
}
else {
std.log("blobs not equal");
}
}
} -start
varnish v2 -vcl {
backend b { .host = "${bad_ip}"; }
}
logexpect l2 -v v2 -d 0 -g raw -q "VCL_Log" {
expect 0 * VCL_Log "^blobs are equal$"
} -start
varnish v2 -cliok "vcl.use vcl2"
varnish v2 -cliok "vcl.discard vcl1"
logexpect l2 -wait
......@@ -56,9 +56,6 @@
#define INIT_FINI(ctx) (((ctx)->method & (VCL_MET_INIT | VCL_MET_FINI)) != 0)
#define ILLEGAL(ctx, m) \
ERR((ctx), m " is illegal in vcl_init() and vcl_fini().")
struct digest_task {
unsigned magic;
#define VMOD_BLOBDIGEST_DIGEST_TASK_MAGIC 0x646937a8
......@@ -505,10 +502,6 @@ vmod_hash(VRT_CTX, VCL_ENUM hashs, VCL_BLOB msg)
hash_ctx hctx[1];
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
if (INIT_FINI(ctx)) {
ILLEGAL(ctx, "hash()");
return NULL;
}
if (msg == NULL)
return NULL;
......
......@@ -412,8 +412,9 @@ Example::
REQUIREMENTS
============
This VMOD requires at least Varnish version 4.1, and has been tested
against versions through 5.0.0.
This version of the VMOD requires Varnish version 5.0.0. See branch
4.1 in the source repository for versions that are compatible with
Varnish 4.1.
The gcc compiler and Perl 5 are required for the build. For the
self-tests invoked by ``make check``, the VMODs ``blobcode`` and
......
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