File tree Expand file tree Collapse file tree 3 files changed +45
-8
lines changed Expand file tree Collapse file tree 3 files changed +45
-8
lines changed Original file line number Diff line number Diff line change 22
22
#include <lauxlib.h>
23
23
24
24
25
+ #if (NGX_PCRE )
26
+
27
+ #include <pcre.h>
28
+
29
+ #if (PCRE_MAJOR > 8 ) || (PCRE_MAJOR == 8 && PCRE_MINOR >= 21 )
30
+ # define LUA_HAVE_PCRE_JIT 1
31
+ #else
32
+ # define LUA_HAVE_PCRE_JIT 0
33
+ #endif
34
+
35
+ #endif
36
+
37
+
25
38
#if !defined(nginx_version ) || (nginx_version < 1006000 )
26
39
#error at least nginx 1.6.0 is required but found an older version
27
40
#endif
@@ -159,7 +172,11 @@ struct ngx_http_lua_main_conf_s {
159
172
ngx_int_t regex_cache_entries ;
160
173
ngx_int_t regex_cache_max_entries ;
161
174
ngx_int_t regex_match_limit ;
162
- pcre_jit_stack jit_stack ;
175
+
176
+ #if (LUA_HAVE_PCRE_JIT )
177
+ pcre_jit_stack * jit_stack ;
178
+ #endif
179
+
163
180
#endif
164
181
165
182
ngx_array_t * shm_zones ; /* of ngx_shm_zone_t* */
Original file line number Diff line number Diff line change 28
28
#include "ngx_http_lua_ssl_certby.h"
29
29
30
30
31
+ #if (NGX_PCRE )
32
+
33
+ #if (PCRE_MAJOR > 8 ) || (PCRE_MAJOR == 8 && PCRE_MINOR >= 21 )
34
+ # define LUA_HAVE_PCRE_JIT 1
35
+ # define NGX_LUA_RE_MIN_JIT_STACK_SIZE 32 * 1024
36
+ #else
37
+ # define LUA_HAVE_PCRE_JIT 0
38
+ #endif
39
+
40
+ #endif
41
+
42
+
31
43
static void * ngx_http_lua_create_main_conf (ngx_conf_t * cf );
32
44
static char * ngx_http_lua_init_main_conf (ngx_conf_t * cf , void * conf );
33
45
static void * ngx_http_lua_create_srv_conf (ngx_conf_t * cf );
@@ -798,7 +810,12 @@ ngx_http_lua_create_main_conf(ngx_conf_t *cf)
798
810
#if (NGX_PCRE )
799
811
lmcf -> regex_cache_max_entries = NGX_CONF_UNSET ;
800
812
lmcf -> regex_match_limit = NGX_CONF_UNSET ;
801
- lmcf -> jit_stack = pcre_jit_stack_alloc (32 * 1024 , 32 * 1024 );
813
+
814
+ #if (LUA_HAVE_PCRE_JIT )
815
+ lmcf -> jit_stack = pcre_jit_stack_alloc (NGX_LUA_RE_MIN_JIT_STACK_SIZE ,
816
+ NGX_LUA_RE_MIN_JIT_STACK_SIZE );
817
+ #endif
818
+
802
819
#endif
803
820
lmcf -> postponed_to_rewrite_phase_end = NGX_CONF_UNSET ;
804
821
lmcf -> postponed_to_access_phase_end = NGX_CONF_UNSET ;
Original file line number Diff line number Diff line change 42
42
43
43
#define NGX_LUA_RE_DFA_MODE_WORKSPACE_COUNT (100)
44
44
45
+ #define NGX_LUA_RE_MIN_JIT_STACK_SIZE 32 * 1024
46
+
45
47
46
48
typedef struct {
47
49
#ifndef NGX_LUA_NO_FFI_API
@@ -2481,20 +2483,21 @@ ngx_http_lua_ffi_max_regex_cache_size(void)
2481
2483
return (uint32_t ) lmcf -> regex_cache_max_entries ;
2482
2484
}
2483
2485
2486
+
2484
2487
void
2485
2488
ngx_http_lua_ffi_set_jit_stack_size (int size )
2486
2489
{
2487
- int min_size ;
2488
2490
ngx_http_lua_main_conf_t * lmcf ;
2489
2491
2490
- min_size = MIN (32 * 1024 , size );
2491
- lmcf = ngx_http_cycle_get_module_main_conf (ngx_cycle ,
2492
- ngx_http_lua_module );
2493
- if (lmcf == NULL ) {
2492
+ if (size < NGX_LUA_RE_MIN_JIT_STACK_SIZE ) {
2494
2493
return ;
2495
2494
}
2495
+
2496
+ lmcf = ngx_http_cycle_get_module_main_conf (ngx_cycle ,
2497
+ ngx_http_lua_module );
2496
2498
pcre_jit_stack_free (lmcf -> jit_stack );
2497
- lmcf -> jit_stack = pcre_jit_stack_alloc (min_size , size );
2499
+ lmcf -> jit_stack = pcre_jit_stack_alloc (NGX_LUA_RE_MIN_JIT_STACK_SIZE ,
2500
+ size );
2498
2501
}
2499
2502
#endif /* NGX_LUA_NO_FFI_API */
2500
2503
You can’t perform that action at this time.
0 commit comments