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