Commit c91432f1 authored by Geoff Simmons's avatar Geoff Simmons

use the event function to initialize the size of RE2 match data

parent a438c7b1
......@@ -71,7 +71,6 @@ static char c;
static const void *match_failed = (void *) &c;
static size_t match_sz;
static pthread_once_t sz_init_once = PTHREAD_ONCE_INIT;
static void
errmsg(VRT_CTX, const char *fmt, ...)
......@@ -92,12 +91,6 @@ errmsg(VRT_CTX, const char *fmt, ...)
va_end(args);
}
static void
init_matchsz(void)
{
match_sz = vre2_matchsz();
}
static void
free_task_match(void *p)
{
......@@ -231,6 +224,19 @@ namedref(VRT_CTX, vre2 * restrict vre2, VCL_STRING name, VCL_STRING fallback,
#undef ERR_PREFIX
/* Event function */
int
event(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e)
{
(void) ctx;
(void) priv;
if (e == VCL_EVENT_LOAD)
match_sz = vre2_matchsz();
return 0;
}
VCL_VOID
vmod_regex__init(const struct vrt_ctx *ctx, struct vmod_re2_regex **rep,
const char *vcl_name, VCL_STRING pattern, VCL_BOOL utf8,
......@@ -271,7 +277,6 @@ vmod_regex__init(const struct vrt_ctx *ctx, struct vmod_re2_regex **rep,
}
re->never_capture = never_capture;
re->vcl_name = strdup(vcl_name);
AZ(pthread_once(&sz_init_once, init_matchsz));
}
VCL_VOID
......
......@@ -9,6 +9,8 @@
$Module re2 3 access the Google RE2 regular expression engine
$Event event
$Object regex(STRING pattern, BOOL utf8=0, BOOL posix_syntax=0,
BOOL longest_match=0, INT max_mem=8388608, BOOL literal=0,
BOOL never_nl=0, BOOL dot_nl=0, BOOL never_capture=0,
......
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