From ecfee1665065e180406789fdefb2c5e0fdde3ce1 Mon Sep 17 00:00:00 2001 From: lijunlong Date: Sat, 21 May 2022 16:41:27 +0800 Subject: [PATCH 1/2] optimize: add error log when closing the pipe failed. --- src/ngx_http_lua_pipe.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/ngx_http_lua_pipe.c b/src/ngx_http_lua_pipe.c index 93dc7d5bc5..15c0aa696f 100644 --- a/src/ngx_http_lua_pipe.c +++ b/src/ngx_http_lua_pipe.c @@ -773,10 +773,21 @@ ngx_http_lua_ffi_pipe_spawn(ngx_http_lua_ffi_pipe_proc_t *proc, } } - close(in[0]); - close(out[1]); + if (close(in[0]) == -1) { + ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, + "lua pipe failed to close the in[0]"); + } + + if (close(out[1]) == -1) { + ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, + "lua pipe failed to close the out[1]"); + } + if (!merge_stderr) { - close(err[1]); + if (close(err[1]) == -1) { + ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, + "lua pipe failed to close the err[1]"); + } } if (environ != NULL) { From 9678596ce015605595cae6e057a30a6e747e72f0 Mon Sep 17 00:00:00 2001 From: lijunlong Date: Sun, 22 May 2022 17:59:34 +0800 Subject: [PATCH 2/2] failed to build. --- src/ngx_http_lua_pipe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ngx_http_lua_pipe.c b/src/ngx_http_lua_pipe.c index 15c0aa696f..b1db8ac1c2 100644 --- a/src/ngx_http_lua_pipe.c +++ b/src/ngx_http_lua_pipe.c @@ -774,18 +774,18 @@ ngx_http_lua_ffi_pipe_spawn(ngx_http_lua_ffi_pipe_proc_t *proc, } if (close(in[0]) == -1) { - ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, + ngx_log_error(NGX_LOG_EMERG, ngx_cycle->log, ngx_errno, "lua pipe failed to close the in[0]"); } if (close(out[1]) == -1) { - ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, + ngx_log_error(NGX_LOG_EMERG, ngx_cycle->log, ngx_errno, "lua pipe failed to close the out[1]"); } if (!merge_stderr) { if (close(err[1]) == -1) { - ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, + ngx_log_error(NGX_LOG_EMERG, ngx_cycle->log, ngx_errno, "lua pipe failed to close the err[1]"); } }