
phk at varnish-cache
Apr 30, 2012, 11:40 PM
Post #1 of 1
(50 views)
Permalink
|
|
[master] 9190dc3 Add 16k more thread stack to cater for PCRE-JIT.
|
|
commit 9190dc3602bb65e4a8423f2defedf62145742641 Author: Poul-Henning Kamp <phk [at] FreeBSD> Date: Tue May 1 06:38:54 2012 +0000 Add 16k more thread stack to cater for PCRE-JIT. Polish vre.c a bit with respect to memory management and error messages. diff --git a/bin/varnishd/mgt/mgt_pool.c b/bin/varnishd/mgt/mgt_pool.c index e5d5cd0..986d405 100644 --- a/bin/varnishd/mgt/mgt_pool.c +++ b/bin/varnishd/mgt/mgt_pool.c @@ -215,6 +215,6 @@ const struct parspec WRK_parspec[] = { "This is likely rounded up to a multiple of 4k by the kernel.\n" "The kernel/OS has a lower limit which will be enforced.\n", EXPERIMENTAL, - "32k", "bytes" }, + "48k", "bytes" }, { NULL, NULL, NULL } }; diff --git a/lib/libvarnish/vre.c b/lib/libvarnish/vre.c index ee462c7..2fce5c7 100644 --- a/lib/libvarnish/vre.c +++ b/lib/libvarnish/vre.c @@ -37,17 +37,22 @@ #include "vre.h" +#ifndef PCRE_STUDY_JIT_COMPILE +#define PCRE_STUDY_JIT_COMPILE 0 +#endif + +#if PCRE_MAJOR < 8 || (PCRE_MAJOR == 8 && PCRE_MINOR < 20) +# define pcre_free_study pcre_free +#endif + struct vre { unsigned magic; #define VRE_MAGIC 0xe83097dc pcre *re; pcre_extra *re_extra; + int my_extra; }; -#ifndef PCRE_STUDY_JIT_COMPILE -#define PCRE_STUDY_JIT_COMPILE 0 -#endif - /* * We don't want to spread or even expose the majority of PCRE options * so we establish our own options and implement hard linkage to PCRE @@ -58,29 +63,32 @@ const unsigned VRE_NOTEMPTY = PCRE_NOTEMPTY; vre_t * VRE_compile(const char *pattern, int options, - const char **errptr, int *erroffset) + const char **errptr, int *erroffset) { vre_t *v; *errptr = NULL; *erroffset = 0; ALLOC_OBJ(v, VRE_MAGIC); - if (v == NULL) + if (v == NULL) { + *errptr = "Out of memory for VRE"; return (NULL); + } v->re = pcre_compile(pattern, options, errptr, erroffset, NULL); if (v->re == NULL) { VRE_free(&v); return (NULL); } v->re_extra = pcre_study(v->re, PCRE_STUDY_JIT_COMPILE, errptr); + if (*errptr != NULL) { + VRE_free(&v); + return (NULL); + } if (v->re_extra == NULL) { - if (*errptr != NULL) { - VRE_free(&v); - return (NULL); - } - /* allocate our own, pcre_study can return NULL without it - * being an error */ + /* allocate our own */ v->re_extra = calloc(1, sizeof(pcre_extra)); + v->my_extra = 1; if (v->re_extra == NULL) { + *errptr = "Out of memory for pcre_extra"; VRE_free(&v); return (NULL); } @@ -122,11 +130,13 @@ VRE_free(vre_t **vv) *vv = NULL; CHECK_OBJ(v, VRE_MAGIC); -#ifdef PCRE_CONFIG_JIT - pcre_free_study(v->re_extra); -#else - free(v->re_extra); -#endif - pcre_free(v->re); + if (v->re_extra != NULL) { + if (v->my_extra) + free(v->re_extra); + else + pcre_free_study(v->re_extra); + } + if (v->re != NULL) + pcre_free(v->re); FREE_OBJ(v); } _______________________________________________ varnish-commit mailing list varnish-commit [at] varnish-cache https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit
|