3232#include "ngx_http_lua_log.h"
3333
3434
35- #define LJ_CHUNKNAME_MAX_LEN 42
35+ /* the max length is 60, after deducting the fixed four characters "=(:)"
36+ * only 56 left.
37+ */
38+ #define LJ_CHUNKNAME_MAX_LEN 56
3639
3740
3841typedef struct ngx_http_lua_block_parser_ctx_s
@@ -1369,7 +1372,7 @@ ngx_http_lua_gen_chunk_name(ngx_conf_t *cf, const char *tag, size_t tag_len,
13691372 ngx_str_t * filename ;
13701373 u_char * filename_end ;
13711374 const char * pre_str = "" ;
1372- ngx_uint_t start_line_len ;
1375+ ngx_uint_t reserve_len ;
13731376
13741377 ngx_http_lua_main_conf_t * lmcf ;
13751378
@@ -1385,7 +1388,7 @@ ngx_http_lua_gen_chunk_name(ngx_conf_t *cf, const char *tag, size_t tag_len,
13851388 start_line = lmcf -> directive_line > 0
13861389 ? lmcf -> directive_line : cf -> conf_file -> line ;
13871390 p = ngx_snprintf (out , len , "%d" , start_line );
1388- start_line_len = p - out ;
1391+ reserve_len = tag_len + p - out ;
13891392
13901393 filename = & cf -> conf_file -> file .name ;
13911394 filename_end = filename -> data + filename -> len ;
@@ -1407,8 +1410,8 @@ ngx_http_lua_gen_chunk_name(ngx_conf_t *cf, const char *tag, size_t tag_len,
14071410 filename -> data , conf_prefix -> len ) == 0 )
14081411 {
14091412 /* files in conf_prefix directory, use the relative path */
1410- if (filename_end - p + start_line_len > LJ_CHUNKNAME_MAX_LEN ) {
1411- p = filename_end - LJ_CHUNKNAME_MAX_LEN + start_line_len + 3 ;
1413+ if (filename_end - p + reserve_len > LJ_CHUNKNAME_MAX_LEN ) {
1414+ p = filename_end - LJ_CHUNKNAME_MAX_LEN + reserve_len + 3 ;
14121415 pre_str = "..." ;
14131416 }
14141417
@@ -1418,11 +1421,11 @@ ngx_http_lua_gen_chunk_name(ngx_conf_t *cf, const char *tag, size_t tag_len,
14181421
14191422 p = filename -> data ;
14201423
1421- if (filename -> len + start_line_len <= LJ_CHUNKNAME_MAX_LEN ) {
1424+ if (filename -> len + reserve_len <= LJ_CHUNKNAME_MAX_LEN ) {
14221425 goto found ;
14231426 }
14241427
1425- p = filename_end - LJ_CHUNKNAME_MAX_LEN + start_line_len + 3 ;
1428+ p = filename_end - LJ_CHUNKNAME_MAX_LEN + reserve_len + 3 ;
14261429 pre_str = "..." ;
14271430
14281431found :
0 commit comments