{ "recipient_verify_failure",vtype_stringptr,&recipient_verify_failure },
{ "recipients", vtype_string_func, (void *) &fn_recipients },
{ "recipients_count", vtype_int, &recipients_count },
+ { "regex_cachesize", vtype_int, ®ex_cachesize },/* undocumented; devel observability */
#ifdef WITH_CONTENT_SCAN
{ "regex_match_string", vtype_stringptr, ®ex_match_string },
#endif
#ifndef DISABLE_PIPE_CONNECT
const pcre2_code *regex_EARLY_PIPE = NULL;
#endif
+int regex_cachesize = 0;
const pcre2_code *regex_ismsgid = NULL;
const pcre2_code *regex_smtp_code = NULL;
const uschar *regex_vars[REGEX_VARS];
#ifndef DISABLE_PIPE_CONNECT
extern const pcre2_code *regex_EARLY_PIPE; /* For recognizing PIPE_CONNCT */
#endif
+extern int regex_cachesize; /* number of entries */
extern const pcre2_code *regex_ismsgid; /* Compiled r.e. for message ID */
extern const pcre2_code *regex_smtp_code; /* For recognizing SMTP codes */
extern const uschar *regex_vars[]; /* $regexN variables */
static tree_node * regex_cache = NULL;
static tree_node * regex_caseless_cache = NULL;
+#define REGEX_CACHESIZE_LIMIT 1000
+
/******************************************************************************/
static void
{
const re_req * req = (const re_req *)reqbuf;
uschar * errstr;
-const pcre2_code * cre = regex_compile(req->re,
- req->caseless ? MCS_CASELESS | MCS_CACHEABLE : MCS_CACHEABLE,
- &errstr, pcre_gen_cmp_ctx);
+const pcre2_code * cre;
+
+if (regex_cachesize >= REGEX_CACHESIZE_LIMIT)
+ errstr = US"regex cache size limit reached";
+else if ((cre = regex_compile(req->re,
+ req->caseless ? MCS_CASELESS | MCS_CACHEABLE : MCS_CACHEABLE,
+ &errstr, pcre_gen_cmp_ctx)))
+ regex_cachesize++;
DEBUG(D_any) if (!cre) debug_printf("%s\n", errstr);
return;