Skip to content

Commit cfb5825

Browse files
tests: fix stream get_upstream_ssl_pointer test for the log phase.
TEST 31 in t/stream/ssl.t relied on the previous 'not ssl' bug in ngx.ssl.get_upstream_ssl_pointer(), which never detected a NULL cdata and so masked that the upstream connection is already released by the time log_by_lua runs in the stream subsystem. With the NULL check fixed the API now correctly returns 'not upstream' in that phase. Update the test to assert the real behaviour (and guard against the NULL-detection regression) instead of expecting a stale 'session reused: false' from ssl_session_reused() on a NULL pointer.
1 parent a60ab0e commit cfb5825

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

t/stream/ssl.t

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2517,9 +2517,11 @@ qr/ssl pointer: cdata<void \*>: 0x[0-9a-f]+,/
25172517
25182518
25192519
2520-
=== TEST 31: get upstream SSL pointer
2520+
=== TEST 31: get upstream SSL pointer (released in the log phase)
25212521
Just for test api.
2522-
The ssl_session_reuesed is always false in log_by_lua phase.
2522+
In the stream subsystem the upstream connection is already released by the
2523+
time log_by_lua runs, so get_upstream_ssl_pointer() reports "not upstream"
2524+
instead of returning a stale/NULL pointer.
25232525
--- stream_config
25242526
lua_package_path "$TEST_NGINX_LUA_PACKAGE_PATH";
25252527

@@ -2537,17 +2539,17 @@ The ssl_session_reuesed is always false in log_by_lua phase.
25372539
log_by_lua_block {
25382540
local ssl = require "ngx.ssl"
25392541
local ssl_conn, err = ssl.get_upstream_ssl_pointer()
2540-
if err ~= nil then
2541-
ngx.log(ngx.ERR, "failed to get ssl pointer: ", err)
2542+
if not ssl_conn then
2543+
ngx.log(ngx.WARN, "failed to get upstream ssl pointer: ", err)
25422544
return
25432545
end
25442546
ngx.log(ngx.INFO, "session reused: ", ssl.ssl_session_reused(ssl_conn))
25452547
}
25462548

25472549
--- stream_response
25482550
it works!
2549-
--- error_log eval
2550-
qr/session reused: false/
2551+
--- error_log
2552+
failed to get upstream ssl pointer: not upstream
25512553
--- no_error_log
25522554
[alert]
25532555
[crit]

0 commit comments

Comments
 (0)