Commit c7583ca9 authored by Geoff Simmons's avatar Geoff Simmons

Update use of the WS_* interface for compatibility with Varnish since 5.1.0.

parent 0da78435
......@@ -139,6 +139,7 @@ match(VRT_CTX, vre2 * restrict vre2, VCL_STRING restrict subject,
int match = 0, len;
const char *err;
char *text = (void *) subject;
uintptr_t snap;
AN(groups);
if (subject == NULL)
......@@ -146,6 +147,7 @@ match(VRT_CTX, vre2 * restrict vre2, VCL_STRING restrict subject,
len = strlen(subject);
*groups = NULL;
snap = WS_Snapshot(ctx->ws);
if (!never_capture) {
ngroups++;
if ((text = WS_Copy(ctx->ws, subject, len + 1)) == NULL) {
......@@ -157,7 +159,7 @@ match(VRT_CTX, vre2 * restrict vre2, VCL_STRING restrict subject,
== NULL) {
VERR(ctx, ERR_PREFIX "insufficient workspace to "
"allocate match data", subject);
WS_Reset(ctx->ws, text);
WS_Reset(ctx->ws, snap);
return 0;
}
}
......@@ -166,14 +168,14 @@ match(VRT_CTX, vre2 * restrict vre2, VCL_STRING restrict subject,
!= NULL) {
VERR(ctx, ERR_PREFIX "%s", subject, err);
if (!never_capture)
WS_Reset(ctx->ws, text);
WS_Reset(ctx->ws, snap);
return 0;
}
if (!match) {
*groups = (void *)match_failed;
if (!never_capture)
WS_Reset(ctx->ws, text);
WS_Reset(ctx->ws, snap);
}
return match;
}
......@@ -263,7 +265,7 @@ rewritef(VRT_CTX, vre2 * restrict vre2, const rewrite_e mode, VCL_STRING text,
char *ret;
const char *err;
ret = WS_Snapshot(ctx->ws);
ret = WS_Front(ctx->ws);
bytes = WS_Reserve(ctx->ws, 0);
if (bytes == 0) {
VERR(ctx, ERR_PREFIX "workspace overflow", rewrite_name[mode],
......@@ -705,7 +707,7 @@ vmod_set_match(VRT_CTX, struct vmod_re2_set *set, VCL_STRING subject)
CAST_OBJ(task, priv->priv, TASK_SET_MATCH_MAGIC);
}
buf = WS_Snapshot(ctx->ws);
buf = WS_Front(ctx->ws);
buflen = WS_Reserve(ctx->ws, 0);
if ((err = vre2set_match(set->set, subject, &match, buf, buflen,
&task->nmatches)) != NULL) {
......
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