Skip to content

Commit 5bbb279

Browse files
committed
Add error messages
1 parent e88323b commit 5bbb279

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/resty/core/regex.lua

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ ffi.cdef[[
136136

137137
uint32_t ngx_http_lua_ffi_max_regex_cache_size(void);
138138

139-
void ngx_http_lua_ffi_set_jit_stack_size(int size);
140-
139+
int ngx_http_lua_set_jit_stack_size(int size);
141140
]]
142141

143142

@@ -165,12 +164,22 @@ local function get_max_regex_cache_size()
165164
return max_regex_cache_size
166165
end
167166

167+
168168
function ngx.re.opt(option, value)
169169
if option == "jit_stack_size" then
170-
C.ngx_http_lua_ffi_set_jit_stack_size(value)
170+
local result = C.ngx_http_lua_set_jit_stack_size(value)
171+
172+
if result ~= 0 then
173+
return error("PCRE jit stack allocation failed")
174+
end
175+
176+
return
171177
end
178+
179+
return error("unrecognized option name")
172180
end
173181

182+
174183
local function parse_regex_opts(opts)
175184
local t = cached_re_opts[opts]
176185
if t then

0 commit comments

Comments
 (0)