diff options
author | Igor Sysoev <igor@sysoev.ru> | 2004-07-07 15:01:00 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2004-07-07 15:01:00 +0000 |
commit | 2b97993c7a6525bf41c694414450943d39605757 (patch) | |
tree | b3b3870575cd65e64ef59de5359bfdd3695bc77c /src/core/ngx_regex.c | |
parent | c78c41cefcf1e1fa8005f81b7c6cc0c857bcf46f (diff) | |
download | nginx-2b97993c7a6525bf41c694414450943d39605757.tar.gz nginx-2b97993c7a6525bf41c694414450943d39605757.zip |
nginx-0.0.7-2004-07-07-19:01:00 import
Diffstat (limited to 'src/core/ngx_regex.c')
-rw-r--r-- | src/core/ngx_regex.c | 50 |
1 files changed, 44 insertions, 6 deletions
diff --git a/src/core/ngx_regex.c b/src/core/ngx_regex.c index 617fddcbb..f4d827d83 100644 --- a/src/core/ngx_regex.c +++ b/src/core/ngx_regex.c @@ -7,7 +7,6 @@ static void *ngx_regex_malloc(size_t size); 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 *pattern, ngx_int_t options, /* 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, ngx_str_t *s, 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; |