Mercurial > hg > nginx
diff src/core/ngx_regex.c @ 381:02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 07 Jul 2004 15:01:00 +0000 |
parents | 5cfd65b8b0a7 |
children | da8c5707af39 |
line wrap: on
line diff
--- a/src/core/ngx_regex.c +++ b/src/core/ngx_regex.c @@ -7,7 +7,6 @@ static void *ngx_regex_malloc(size_t siz static void ngx_regex_free(void *p); -/* THREADS: this pool should be private for each thread */ static ngx_pool_t *ngx_pcre_pool; @@ -21,12 +20,29 @@ void ngx_regex_init() ngx_regex_t *ngx_regex_compile(ngx_str_t *pattern, ngx_int_t options, ngx_pool_t *pool, ngx_str_t *err) { - int erroff; - const char *errstr; - ngx_regex_t *re; + int erroff; + const char *errstr; + ngx_regex_t *re; +#if (NGX_THREADS) + ngx_core_tls_t *tls; + +#if (NGX_SUPPRESS_WARN) + tls = NULL; +#endif + + if (ngx_threaded) { + tls = ngx_thread_get_tls(ngx_core_tls_key); + tls->pool = pool; + } else { + ngx_pcre_pool = pool; + } + +#else ngx_pcre_pool = pool; +#endif + re = pcre_compile((const char *) pattern->data, (int) options, &errstr, &erroff, NULL); @@ -44,7 +60,15 @@ ngx_regex_t *ngx_regex_compile(ngx_str_t /* ensure that there is no current pool */ +#if (NGX_THREADS) + if (ngx_threaded) { + tls->pool = NULL; + } else { + ngx_pcre_pool = NULL; + } +#else ngx_pcre_pool = NULL; +#endif return re; } @@ -68,8 +92,22 @@ ngx_int_t ngx_regex_exec(ngx_regex_t *re static void *ngx_regex_malloc(size_t size) { - if (ngx_pcre_pool) { - return ngx_palloc(ngx_pcre_pool, size); + ngx_pool_t *pool; +#if (NGX_THREADS) + ngx_core_tls_t *tls; + + if (ngx_threaded) { + tls = ngx_thread_get_tls(ngx_core_tls_key); + pool = tls->pool; + } else { + pool = ngx_pcre_pool; + } +#else + pool = ngx_pcre_pool; +#endif + + if (pool) { + return ngx_palloc(pool, size); } return NULL;