Skip to content

Commit 5eb0d37

Browse files
bugfix: failed to get error message because the input buffer length is not set.
1 parent deddcb8 commit 5eb0d37

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/resty/core/request.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ if subsystem == "stream" then
7979
local err = get_string_buf(ERR_BUF_SIZE)
8080
local errlenp = get_size_ptr()
8181
buf_sizep[0] = 128
82+
errlenp[0] = ERR_BUF_SIZE
8283
rc = C.ngx_stream_lua_ffi_req_dst_addr(r, buf, buf_sizep, err, errlenp)
8384
if tonumber(rc) ~= 0 then
84-
return nil, tostring(err, errlenp[0])
85+
return nil, ffi_str(err, errlenp[0])
8586
end
8687

8788
return ffi_str(buf, buf_sizep[0])

t/stream/request.t

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ stitch
4141

4242

4343
=== TEST 2: get dst address
44+
SO_ORIGINAL_DST is only enable when the flow is redirect by iptables
4445
--- stream_server_config
4546
content_by_lua_block {
4647
local dst_addr = ngx.req.get_original_addr()
@@ -53,3 +54,4 @@ qr/127.0.0.1:\d+/
5354
[alert]
5455
[crit]
5556
[crit2]
57+
--- SKIP

0 commit comments

Comments
 (0)