Skip to content

Commit 3c3d078

Browse files
optimize: destroy pipe when freeing request. (#394)
1 parent 1b43b89 commit 3c3d078

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

lib/ngx/pipe.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ typedef struct {
4747
ngx_http_lua_pipe_t *pipe;
4848
} ngx_http_lua_ffi_pipe_proc_t;
4949

50-
int ngx_http_lua_ffi_pipe_spawn(ngx_http_lua_ffi_pipe_proc_t *proc,
50+
int ngx_http_lua_ffi_pipe_spawn(ngx_http_request_t *r,
51+
ngx_http_lua_ffi_pipe_proc_t *proc,
5152
const char *file, const char **argv, int merge_stderr, size_t buffer_size,
5253
const char **environ, u_char *errbuf, size_t *errbuf_size);
5354

@@ -624,8 +625,9 @@ do
624625

625626
local errbuf = get_string_buf(ERR_BUF_SIZE)
626627
local errbuf_size = get_size_ptr()
628+
local r = get_request()
627629
errbuf_size[0] = ERR_BUF_SIZE
628-
local rc = C.ngx_http_lua_ffi_pipe_spawn(proc, exe, proc_args,
630+
local rc = C.ngx_http_lua_ffi_pipe_spawn(r, proc, exe, proc_args,
629631
merge_stderr, buffer_size,
630632
proc_envs, errbuf, errbuf_size)
631633
if rc == FFI_ERROR then

t/pipe.t

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,10 @@ lua pipe kill process:
13611361
}
13621362
--- response_body
13631363
ok
1364-
--- shutdown_error_log
1364+
--- error_log
1365+
lua pipe destroy process:
1366+
lua pipe kill process:
1367+
--- no_shutdown_error_log
13651368
lua pipe destroy process:
13661369
lua pipe kill process:
13671370

0 commit comments

Comments
 (0)