Skip to content

Commit 5f47838

Browse files
doujiang24zhuizhuhaomeng
authored andcommitted
doc: clearify the missing the closing long bracket may due to the lua code is too long.
1 parent 3f1c683 commit 5f47838

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

README.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,8 @@ As noted earlier, PCRE sequences presented within `*_by_lua_block {}` directives
908908
# evaluates to "1234"
909909
```
910910

911+
**NOTE** You are recommended to use `by_lua_file` when the Lua code is very long.
912+
911913
[Back to TOC](#table-of-contents)
912914

913915
Mixing with SSI Not Supported

doc/HttpLuaModule.wiki

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ As noted earlier, PCRE sequences presented within <code>*_by_lua_block {}</code>
755755
# evaluates to "1234"
756756
</geshi>
757757
758+
'''NOTE''' You are recommended to use `by_lua_file` when the Lua code is very long.
759+
758760
== Mixing with SSI Not Supported ==
759761
760762
Mixing SSI with ngx_lua in the same Nginx request is not supported at all. Just use ngx_lua exclusively. Everything you can do with SSI can be done atop ngx_lua anyway and it can be more efficient when using ngx_lua.

src/ngx_http_lua_directive.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,7 +1537,7 @@ ngx_http_lua_conf_read_lua_token(ngx_conf_t *cf,
15371537
for ( ;; ) {
15381538

15391539
if (b->pos >= b->last
1540-
|| (b->last - b->pos < (b->end - b->start) / 3
1540+
|| (b->last - b->pos < (b->end - b->start) / 2
15411541
&& cf->conf_file->file.offset < file_size))
15421542
{
15431543

@@ -1709,7 +1709,8 @@ ngx_http_lua_conf_read_lua_token(ngx_conf_t *cf,
17091709
if (q == NULL) {
17101710
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
17111711
"Lua code block missing the closing "
1712-
"long bracket \"%*s\"",
1712+
"long bracket \"%*s\", "
1713+
"the inlined Lua code may be too long",
17131714
b->pos + ovec[1] - p, p);
17141715
return NGX_ERROR;
17151716
}

t/132-lua-blocks.t

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ hello, world
312312
[error]
313313
--- must_die
314314
--- error_log eval
315-
qr/\[emerg\] .*? Lua code block missing the closing long bracket "]]" in .*?\bnginx\.conf:41/
315+
qr/\[emerg\] .*? Lua code block missing the closing long bracket "]]", the inlined Lua code may be too long in .*?\bnginx\.conf:41/
316316
317317
318318
@@ -331,7 +331,7 @@ hello, world
331331
[error]
332332
--- must_die
333333
--- error_log eval
334-
qr/\[emerg\] .*? Lua code block missing the closing long bracket "]==]" in .*?\bnginx\.conf:41/
334+
qr/\[emerg\] .*? Lua code block missing the closing long bracket "]==]", the inlined Lua code may be too long in .*?\bnginx.conf:41/
335335
336336
337337
@@ -350,7 +350,7 @@ hello, world
350350
[error]
351351
--- must_die
352352
--- error_log eval
353-
qr/\[emerg\] .*? Lua code block missing the closing long bracket "]]" in .*?\bnginx\.conf:41/
353+
qr/\[emerg\] .*? Lua code block missing the closing long bracket "]]", the inlined Lua code may be too long in .*?\bnginx\.conf:41/
354354
355355
356356
@@ -369,7 +369,7 @@ hello, world
369369
[error]
370370
--- must_die
371371
--- error_log eval
372-
qr/\[emerg\] .*? Lua code block missing the closing long bracket "]=]" in .*?\bnginx\.conf:41/
372+
qr/\[emerg\] .*? Lua code block missing the closing long bracket "]=]", the inlined Lua code may be too long in .*?\bnginx\.conf:41/
373373
374374
375375

0 commit comments

Comments
 (0)