[nginx] svn commit: r4424 - trunk/src/core

rickytato rickytato rickytato at r2consulting.it
Wed Feb 22 16:44:09 UTC 2012


I'm trying to compile Nginx with pcre jit support but I've an error:


objs/src/core/ngx_regex.o: In function `ngx_pcre_free_studies':
/usr/local/src/nginx-1.1.15/src/core/ngx_regex.c:307: undefined
reference to `pcre_free_study'
collect2: ld returned 1 exit status
make[1]: *** [objs/nginx] Error 1


I'v compiled pcre-8.21 with: ./configure --prefix=/usr/local/
--enable-jit --enable-utf8 --enable-unicode-properties
but nginx won't compile.


rr

2012/1/30  <vbart at nginx.com>:
> Author: vbart
> Date: 2012-01-30 12:53:57 +0000 (Mon, 30 Jan 2012)
> New Revision: 4424
>
> Modified:
>   trunk/src/core/ngx_regex.c
> Log:
> Fixed memory leak on HUP signal when PCRE JIT was used.
>
> The PCRE JIT compiler uses mmap to allocate memory for its executable codes, so
> we have to explicitly call the pcre_free_study() function to free this memory.
>
>
> Modified: trunk/src/core/ngx_regex.c
> ===================================================================
> --- trunk/src/core/ngx_regex.c  2012-01-30 11:22:56 UTC (rev 4423)
> +++ trunk/src/core/ngx_regex.c  2012-01-30 12:53:57 UTC (rev 4424)
> @@ -16,6 +16,9 @@
>
>  static void * ngx_libc_cdecl ngx_regex_malloc(size_t size);
>  static void ngx_libc_cdecl ngx_regex_free(void *p);
> +#if (NGX_HAVE_PCRE_JIT)
> +static void ngx_pcre_free_studies(void *data);
> +#endif
>
>  static ngx_int_t ngx_regex_module_init(ngx_cycle_t *cycle);
>
> @@ -274,6 +277,41 @@
>  }
>
>
> +#if (NGX_HAVE_PCRE_JIT)
> +
> +static void
> +ngx_pcre_free_studies(void *data)
> +{
> +    ngx_list_t *studies = data;
> +
> +    ngx_uint_t        i;
> +    ngx_list_part_t  *part;
> +    ngx_regex_elt_t  *elts;
> +
> +    part = &studies->part;
> +    elts = part->elts;
> +
> +    for (i = 0 ; /* void */ ; i++) {
> +
> +        if (i >= part->nelts) {
> +            if (part->next == NULL) {
> +                break;
> +            }
> +
> +            part = part->next;
> +            elts = part->elts;
> +            i = 0;
> +        }
> +
> +        if (elts[i].regex->extra != NULL) {
> +            pcre_free_study(elts[i].regex->extra);
> +        }
> +    }
> +}
> +
> +#endif
> +
> +
>  static ngx_int_t
>  ngx_regex_module_init(ngx_cycle_t *cycle)
>  {
> @@ -287,12 +325,27 @@
>
>  #if (NGX_HAVE_PCRE_JIT)
>     {
> -    ngx_regex_conf_t  *rcf;
> +    ngx_regex_conf_t    *rcf;
> +    ngx_pool_cleanup_t  *cln;
>
>     rcf = (ngx_regex_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_regex_module);
>
>     if (rcf->pcre_jit) {
>         opt = PCRE_STUDY_JIT_COMPILE;
> +
> +        /*
> +         * The PCRE JIT compiler uses mmap for its executable codes, so we
> +         * have to explicitly call the pcre_free_study() function to free
> +         * this memory.
> +         */
> +
> +        cln = ngx_pool_cleanup_add(cycle->pool, 0);
> +        if (cln == NULL) {
> +            return NGX_ERROR;
> +        }
> +
> +        cln->handler = ngx_pcre_free_studies;
> +        cln->data = ngx_pcre_studies;
>     }
>     }
>  #endif
>
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel



More information about the nginx-devel mailing list