Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 9 additions & 147 deletions t/023-rewrite/uthread-exit.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ our $StapScript = $t::StapThread::StapScript;

repeat_each(2);

plan tests => repeat_each() * (blocks() * 4 + 1);
plan tests => repeat_each() * (blocks() * 4);

$ENV{TEST_NGINX_RESOLVER} ||= '8.8.8.8';
$ENV{TEST_NGINX_MEMCACHED_PORT} ||= '11211';
Expand Down Expand Up @@ -299,7 +299,7 @@ exiting the user thread
--- config
location /lua {
resolver 127.0.0.2:12345;
resolver_timeout 12s;
resolver_timeout 2s;
rewrite_by_lua '
local function f()
ngx.say("hello in thread")
Expand All @@ -321,82 +321,13 @@ exiting the user thread
}
--- request
GET /lua
--- stap2 eval: $::StapScript
--- stap eval
<<'_EOC_' . $::GCScript;

global timers

F(ngx_resolve_start) {
println("resolver started")
}

F(ngx_http_lua_socket_resolve_handler) {
println("resolver done")
}

F(ngx_http_free_request) {
println("free request")
}

F(ngx_resolve_name) {
printf("resolving %s\n", user_string_n($ctx->name->data, $ctx->name->len))
}

M(timer-add) {
if ($arg2 == 12000 || $arg2 == 1) {
timers[$arg1] = $arg2
printf("add timer %d\n", $arg2)
}
}

M(timer-del) {
tm = timers[$arg1]
if (tm == 12000 || tm == 1) {
printf("delete timer %d\n", tm)
delete timers[$arg1]
}
/*
if (tm == 12000) {
print_ubacktrace()
}
*/
}

M(timer-expire) {
tm = timers[$arg1]
if (tm == 12000 || tm == 1) {
printf("expire timer %d\n", timers[$arg1])
delete timers[$arg1]
}
}

F(ngx_http_lua_tcp_resolve_cleanup) {
println("lua tcp resolve cleanup")
}
_EOC_

--- stap_out
create 2 in 1
spawn user thread 2 in 1
add timer 1
resolver started
resolving agentzh.org
add timer 12000
expire timer 1
terminate 2: ok
delete thread 2
lua tcp resolve cleanup
delete timer 12000
delete thread 1
free request

--- response_body
before
hello in thread
after
--- no_error_log
[error]
[crit]



Expand All @@ -405,8 +336,9 @@ after
location /lua {
resolver 127.0.0.2:12345;
#resolver 127.0.0.1;
resolver_timeout 12s;
resolver_timeout 2s;
rewrite_by_lua '
collectgarbage("collect")
local function f()
ngx.say("hello in thread")
ngx.sleep(0.001)
Expand All @@ -427,76 +359,6 @@ after
}
--- request
GET /lua
--- stap2 eval: $::StapScript
--- stap eval
<<'_EOC_' . $::GCScript;

global timers

F(ngx_resolve_start) {
println("resolver started")
}

F(ngx_http_lua_socket_resolve_handler) {
println("resolver done")
}

F(ngx_http_free_request) {
println("free request")
}

F(ngx_resolve_name) {
printf("resolving %s\n", user_string_n($ctx->name->data, $ctx->name->len))
}

M(timer-add) {
if ($arg2 == 12000 || $arg2 == 1) {
timers[$arg1] = $arg2
printf("add timer %d\n", $arg2)
}
}

M(timer-del) {
tm = timers[$arg1]
if (tm == 12000 || tm == 1) {
printf("delete timer %d\n", tm)
delete timers[$arg1]
}
/*
if (tm == 12000) {
print_ubacktrace()
}
*/
}

M(timer-expire) {
tm = timers[$arg1]
if (tm == 12000 || tm == 1) {
printf("expire timer %d\n", timers[$arg1])
delete timers[$arg1]
}
}

F(ngx_http_lua_udp_resolve_cleanup) {
println("lua udp resolve cleanup")
}
_EOC_

--- stap_out
create 2 in 1
spawn user thread 2 in 1
add timer 1
resolver started
resolving agentzh.org
add timer 12000
expire timer 1
terminate 2: ok
delete thread 2
lua udp resolve cleanup
delete timer 12000
delete thread 1
free request

--- response_body
before
hello in thread
Expand Down Expand Up @@ -994,7 +856,7 @@ after
=== TEST 12: exit in user thread (entry thread is still pending on ngx.req.read_body)
--- config
location /lua {
client_body_timeout 12000ms;
client_body_timeout 2000ms;
rewrite_by_lua '
local function f()
ngx.say("hello in thread")
Expand Down Expand Up @@ -1080,7 +942,7 @@ after
=== TEST 13: exit in user thread (entry thread is still pending on ngx.location.capture), with pending output
--- config
location /lua {
client_body_timeout 12000ms;
client_body_timeout 2000ms;
rewrite_by_lua '
local function f()
ngx.say("hello in thread")
Expand Down Expand Up @@ -1164,7 +1026,7 @@ attempt to abort with pending subrequests
=== TEST 14: exit in user thread (entry thread is still pending on ngx.location.capture), without pending output
--- config
location /lua {
client_body_timeout 12000ms;
client_body_timeout 2000ms;
rewrite_by_lua '
local function f()
ngx.sleep(0.1)
Expand Down Expand Up @@ -1247,7 +1109,7 @@ attempt to abort with pending subrequests
=== TEST 15: exit in user thread (entry thread is still pending on ngx.location.capture_multi), without pending output
--- config
location /lua {
client_body_timeout 12000ms;
client_body_timeout 2000ms;
rewrite_by_lua '
local function f()
ngx.sleep(0.1)
Expand Down
Loading
Loading