Skip to content

Commit 096d145

Browse files
committed
synchronized with lua-nginx-module #b2af4d3.
bugfix: inlined Lua code snippets in nginx.conf failed to use the Lua source checksum as part of the Lua code cache key. Thanks Oleg A. Mamo ntov for the report in openresty/lua-nginx-module#1428. Upstream patch from agentzh.
1 parent 6cbddc3 commit 096d145

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/subsys/ngx_subsys_lua_cache.c.tt2

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ ngx_[% subsys %]_lua_cache_loadbuffer(ngx_log_t *log, lua_State *L,
156156

157157
n = lua_gettop(L);
158158

159-
dd("XXX cache key: [% "[%" %]s]", cache_key);
159+
ngx_log_debug1(NGX_LOG_DEBUG_[% SUBSYS %], log, 0,
160+
"looking up Lua code cache with key '%s'", cache_key);
160161

161162
rc = ngx_[% subsys %]_lua_cache_load_code(log, L, (char *) cache_key);
162163
if (rc == NGX_OK) {
@@ -240,7 +241,8 @@ ngx_[% subsys %]_lua_cache_loadfile(ngx_log_t *log, lua_State *L,
240241
dd("CACHE file key already pre-calculated");
241242
}
242243

243-
dd("XXX cache key for file: [% "[%" %]s]", cache_key);
244+
ngx_log_debug1(NGX_LOG_DEBUG_[% SUBSYS %], log, 0,
245+
"looking up Lua code cache with key '%s'", cache_key);
244246

245247
rc = ngx_[% subsys %]_lua_cache_load_code(log, L, (char *) cache_key);
246248
if (rc == NGX_OK) {

src/subsys/ngx_subsys_lua_directive.c.tt2

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,11 +1472,12 @@ ngx_[% subsys %]_lua_gen_chunk_name(ngx_conf_t *cf, const char *tag, size_t tag_
14721472

14731473
found:
14741474

1475-
ngx_snprintf(out, len, "=%*s(%*s:%d)%Z",
1476-
tag_len, tag, cf->conf_file->file.name.data
1477-
+ cf->conf_file->file.name.len - p,
1478-
p, cf->conf_file->line);
1479-
*chunkname_len = len;
1475+
p = ngx_snprintf(out, len, "=%*s(%*s:%d)%Z",
1476+
tag_len, tag, cf->conf_file->file.name.data
1477+
+ cf->conf_file->file.name.len - p,
1478+
p, cf->conf_file->line);
1479+
1480+
*chunkname_len = p - out - 1; /* exclude the trailing '\0' byte */
14801481

14811482
return out;
14821483
}

0 commit comments

Comments
 (0)