File tree 2 files changed +61
-2
lines changed 2 files changed +61
-2
lines changed Original file line number Diff line number Diff line change @@ -1721,14 +1721,17 @@ ngx_http_lua_ngx_re_gmatch_cleanup(void *data)
1721
1721
if (ctx ) {
1722
1722
if (ctx -> regex_sd ) {
1723
1723
dd ("free study data" );
1724
- ngx_http_lua_regex_free_study_data (ctx -> request -> pool , ctx -> regex_sd );
1724
+ ngx_http_lua_regex_free_study_data (ctx -> request -> pool ,
1725
+ ctx -> regex_sd );
1725
1726
ctx -> regex_sd = NULL ;
1726
1727
}
1727
1728
1728
1729
if (ctx -> cleanup ) {
1729
1730
* ctx -> cleanup = NULL ;
1730
1731
ctx -> cleanup = NULL ;
1731
1732
}
1733
+
1734
+ ctx -> request = NULL ;
1732
1735
}
1733
1736
1734
1737
return ;
Original file line number Diff line number Diff line change @@ -9,7 +9,9 @@ use Test::Nginx::Socket;
9
9
10
10
repeat_each(2 );
11
11
12
- plan tests => repeat_each() * (blocks() * 2 );
12
+ plan tests => repeat_each() * (blocks() * 2 + 1 );
13
+
14
+ our $ HtmlDir = html_dir;
13
15
14
16
# no_diff();
15
17
# no_long_string();
@@ -426,3 +428,57 @@ hello
426
428
-- - response_body
427
429
done
428
430
431
+
432
+
433
+ === TEST 19 : gmatch iterator used by another request
434
+ -- - http_config eval
435
+ " lua_package_path '$::HtmlDir/?.lua;;';"
436
+ -- - config
437
+ location / main {
438
+ content_by_lua '
439
+ package.loaded.foo = nil
440
+
441
+ local res = ngx.location.capture("/t")
442
+ if res.status == 200 then
443
+ ngx.print(res.body)
444
+ else
445
+ ngx.say("sr failed: ", res.status)
446
+ end
447
+
448
+ res = ngx.location.capture("/t")
449
+ if res.status == 200 then
450
+ ngx.print(res.body)
451
+ else
452
+ ngx.say("sr failed: ", res.status)
453
+ end
454
+ ' ;
455
+ }
456
+
457
+ location / t {
458
+ content_by_lua '
459
+ local foo = require "foo"
460
+ local m = foo.go()
461
+ ngx.say(m and "matched" or "no")
462
+ ' ;
463
+ }
464
+ -- - user_files
465
+ >>> foo. lua
466
+ module(" foo" , package. seeall)
467
+
468
+ local it
469
+
470
+ function go()
471
+ if not it then
472
+ it = ngx. re . gmatch(" hello, world" , " [a-z]+" )
473
+ end
474
+
475
+ return it()
476
+ end
477
+ -- - request
478
+ GET / main
479
+ -- - response_body
480
+ matched
481
+ sr failed: 500
482
+ -- - error_log
483
+ attempt to use ngx. re . gmatch iterator in a request that did not create it
484
+
You can’t perform that action at this time.
0 commit comments