Commit 8af42be4 authored by Nils Goroll's avatar Nils Goroll

Use VRT_fail for bailing out

Also move tests to vcl_recv for better visibility because VRT_fail
from vcl_synth just closes the connection
parent 770d410d
......@@ -157,26 +157,24 @@ varnish v1 -vcl {
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
if (!d1.update(empty.get())) {
set resp.status = 500;
return(deliver);
return(synth(500));
}
set resp.http.empty = blob.encode(HEX, UPPER, d1.final());
set req.http.empty = blob.encode(HEX, UPPER, d1.final());
if (!d1.update(empty.get())) {
set resp.status = 500;
return(deliver);
return(synth(501));
}
}
sub vcl_synth {
set resp.http.empty = req.http.empty;
}
}
client c1 {
txreq
rxresp
expect resp.status == 500
expect resp.status == 501
expect resp.http.empty == "D41D8CD98F00B204E9800998ECF8427E"
} -run
......@@ -250,28 +248,25 @@ varnish v1 -vcl {
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
if (req.url == "/1") {
set resp.http.obj = blob.encode(HEX, LOWER,
set req.http.obj = blob.encode(HEX, LOWER,
h.hmac(blob.decode(decoding=HEX, encoded="x")));
} else if (req.url == "/2") {
set resp.http.key = blob.encode(
set req.http.key = blob.encode(
encoding=HEX,
blob=blobdigest.hmacf(
MD5,
key=blob.decode(decoding=HEX, encoded="x"),
msg=b.get()));
} else if (req.url == "/3") {
set resp.http.msg = blob.encode(
set req.http.msg = blob.encode(
encoding=HEX,
blob=blobdigest.hmacf(
MD5,
msg=blob.decode(decoding=HEX, encoded="x"),
key=b.get()));
}
return(synth(200));
}
}
......@@ -295,16 +290,22 @@ logexpect l5 -v v1 -d 0 -g vxid -q {ReqURL ~ "^/3"} {
client c1 {
txreq -url "/1"
rxresp
expect resp.status == 503
expect_close
} -run
client c2 {
txreq -url "/2"
rxresp
expect resp.status == 503
expect_close
} -run
client c3 {
txreq -url "/3"
rxresp
expect resp.status == 503
expect_close
} -run
......
......@@ -42,11 +42,11 @@
#include "byte_order.h"
#define ERR(ctx, msg) \
errmsg((ctx), "vmod blobdigest error: " msg)
#define ERR(ctx, msg) \
VRT_fail((ctx), "vmod blobdigest error: " msg)
#define VERR(ctx, fmt, ...) \
errmsg((ctx), "vmod blobdigest error: " fmt, __VA_ARGS__)
#define VERR(ctx, fmt, ...) \
VRT_fail((ctx), "vmod blobdigest error: " fmt, __VA_ARGS__)
#define VERRNOMEM(ctx, fmt, ...) \
VERR((ctx), fmt ", out of space", __VA_ARGS__)
......@@ -81,25 +81,6 @@ struct vmod_blobdigest_hmac {
enum algorithm hash;
};
static void
errmsg(VRT_CTX, const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
if (ctx->method == VCL_MET_INIT) {
AN(ctx->msg);
VSB_vprintf(ctx->msg, fmt, args);
VRT_handling(ctx, VCL_RET_FAIL);
}
else if (ctx->vsl)
VSLbv(ctx->vsl, SLT_VCL_Error, fmt, args);
else
/* Should this ever happen in vcl_fini() ... */
VSL(SLT_VCL_Error, 0, fmt, args);
va_end(args);
}
static void
init(const enum algorithm hash, hash_ctx * const hctx)
{
......
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