From ddfb394eff2ddd14d4a1729bc4a83cf5053f6097 Mon Sep 17 00:00:00 2001 From: Thibault Charbonnier Date: Sun, 28 Jul 2019 13:04:19 -0700 Subject: [PATCH 1/5] optimize: removed declaration of obsolete 'ngx_http_lua_inject_logby_ngx_api' function. This function was removed in 5078b14431f612693a4d468f200b792d128347d6. --- src/ngx_http_lua_logby.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ngx_http_lua_logby.h b/src/ngx_http_lua_logby.h index af8aaaa756..2b011c884e 100644 --- a/src/ngx_http_lua_logby.h +++ b/src/ngx_http_lua_logby.h @@ -14,7 +14,6 @@ ngx_int_t ngx_http_lua_log_handler(ngx_http_request_t *r); ngx_int_t ngx_http_lua_log_handler_inline(ngx_http_request_t *r); ngx_int_t ngx_http_lua_log_handler_file(ngx_http_request_t *r); -void ngx_http_lua_inject_logby_ngx_api(ngx_conf_t *cf, lua_State *L); #endif /* _NGX_HTTP_LUA_LOGBY_H_INCLUDED_ */ From 23bf25dc304473ec4fe90b28958804b532168643 Mon Sep 17 00:00:00 2001 From: Thibault Charbonnier Date: Mon, 29 Jul 2019 10:34:41 -0700 Subject: [PATCH 2/5] optimize: fixed the pre-allocated number of keys in the 'ngx.socket.tcp' table. --- src/ngx_http_lua_socket_tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ngx_http_lua_socket_tcp.c b/src/ngx_http_lua_socket_tcp.c index 87461e6ac2..42abb7e4f2 100644 --- a/src/ngx_http_lua_socket_tcp.c +++ b/src/ngx_http_lua_socket_tcp.c @@ -304,7 +304,7 @@ ngx_http_lua_inject_socket_tcp_api(ngx_log_t *log, lua_State *L) /* {{{tcp object metatable */ lua_pushlightuserdata(L, ngx_http_lua_lightudata_mask( tcp_socket_metatable_key)); - lua_createtable(L, 0 /* narr */, 12 /* nrec */); + lua_createtable(L, 0 /* narr */, 13 /* nrec */); lua_pushcfunction(L, ngx_http_lua_socket_tcp_connect); lua_setfield(L, -2, "connect"); From 4d23434fadf429c451d0ef99342ebd0d33595d33 Mon Sep 17 00:00:00 2001 From: Thibault Charbonnier Date: Sun, 28 Jul 2019 13:05:23 -0700 Subject: [PATCH 3/5] style: fixed some minor styling issues to align with the meta_lua module. --- src/ddebug.h | 32 ++++++++++++++++---------------- src/ngx_http_lua_clfactory.c | 12 ++++++------ src/ngx_http_lua_common.h | 1 - src/ngx_http_lua_log_ringbuf.c | 3 +++ src/ngx_http_lua_module.c | 6 +++--- src/ngx_http_lua_regex.c | 2 +- src/ngx_http_lua_shdict.c | 2 +- src/ngx_http_lua_util.c | 8 ++++---- 8 files changed, 34 insertions(+), 32 deletions(-) diff --git a/src/ddebug.h b/src/ddebug.h index f2d4b738f9..7bf22e9bc1 100644 --- a/src/ddebug.h +++ b/src/ddebug.h @@ -17,8 +17,8 @@ # if (NGX_HAVE_VARIADIC_MACROS) -# define dd(...) fprintf(stderr, "lua *** %s: ", __func__); \ - fprintf(stderr, __VA_ARGS__); \ +# define dd(...) fprintf(stderr, "lua *** %s: ", __func__); \ + fprintf(stderr, __VA_ARGS__); \ fprintf(stderr, " at %s line %d.\n", __FILE__, __LINE__) # else @@ -54,22 +54,22 @@ dd(const char *fmt, ...) { #if defined(DDEBUG) && (DDEBUG) -#define dd_check_read_event_handler(r) \ - dd("r->read_event_handler = %s", \ - r->read_event_handler == ngx_http_block_reading ? \ - "ngx_http_block_reading" : \ - r->read_event_handler == ngx_http_test_reading ? \ - "ngx_http_test_reading" : \ - r->read_event_handler == ngx_http_request_empty_handler ? \ +#define dd_check_read_event_handler(r) \ + dd("r->read_event_handler = %s", \ + r->read_event_handler == ngx_http_block_reading ? \ + "ngx_http_block_reading" : \ + r->read_event_handler == ngx_http_test_reading ? \ + "ngx_http_test_reading" : \ + r->read_event_handler == ngx_http_request_empty_handler ? \ "ngx_http_request_empty_handler" : "UNKNOWN") -#define dd_check_write_event_handler(r) \ - dd("r->write_event_handler = %s", \ - r->write_event_handler == ngx_http_handler ? \ - "ngx_http_handler" : \ - r->write_event_handler == ngx_http_core_run_phases ? \ - "ngx_http_core_run_phases" : \ - r->write_event_handler == ngx_http_request_empty_handler ? \ +#define dd_check_write_event_handler(r) \ + dd("r->write_event_handler = %s", \ + r->write_event_handler == ngx_http_handler ? \ + "ngx_http_handler" : \ + r->write_event_handler == ngx_http_core_run_phases ? \ + "ngx_http_core_run_phases" : \ + r->write_event_handler == ngx_http_request_empty_handler ? \ "ngx_http_request_empty_handler" : "UNKNOWN") #else diff --git a/src/ngx_http_lua_clfactory.c b/src/ngx_http_lua_clfactory.c index 754ed8d2f1..045e46adf9 100644 --- a/src/ngx_http_lua_clfactory.c +++ b/src/ngx_http_lua_clfactory.c @@ -380,12 +380,12 @@ ngx_http_lua_clfactory_bytecode_prepare(lua_State *L, #if defined(DDEBUG) && (DDEBUG) { - dd("==LJ_BT_HEADER=="); - size_t i; - for (i = 0; i < LJ_HEADERSIZE; i++) { - dd("%ld: 0x%02X", i, (unsigned)(u_char) lf->begin_code.str[i]); - } - dd("==LJ_BT_HEADER_END=="); + dd("==LJ_BT_HEADER=="); + size_t i; + for (i = 0; i < LJ_HEADERSIZE; i++) { + dd("%ld: 0x%02X", i, (unsigned)(u_char) lf->begin_code.str[i]); + } + dd("==LJ_BT_HEADER_END=="); } #endif diff --git a/src/ngx_http_lua_common.h b/src/ngx_http_lua_common.h index 44f11b41c9..31ff53ad01 100644 --- a/src/ngx_http_lua_common.h +++ b/src/ngx_http_lua_common.h @@ -628,7 +628,6 @@ typedef struct { ngx_str_t name; ngx_uint_t offset; ngx_http_lua_set_header_pt handler; - } ngx_http_lua_set_header_t; diff --git a/src/ngx_http_lua_log_ringbuf.c b/src/ngx_http_lua_log_ringbuf.c index 04640697ff..0227f63fb2 100644 --- a/src/ngx_http_lua_log_ringbuf.c +++ b/src/ngx_http_lua_log_ringbuf.c @@ -223,3 +223,6 @@ ngx_http_lua_log_ringbuf_read(ngx_http_lua_log_ringbuf_t *rb, int *log_level, return NGX_OK; } + + +/* vi:set ft=c ts=4 sw=4 et fdm=marker: */ diff --git a/src/ngx_http_lua_module.c b/src/ngx_http_lua_module.c index 678b2a3254..afc2f93821 100644 --- a/src/ngx_http_lua_module.c +++ b/src/ngx_http_lua_module.c @@ -1028,7 +1028,7 @@ ngx_http_lua_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) #ifdef LIBRESSL_VERSION_NUMBER ngx_log_error(NGX_LOG_EMERG, cf->log, 0, - "LibreSSL does not support ssl_certificate_by_lua*"); + "LibreSSL is not supported by ssl_certificate_by_lua*"); return NGX_CONF_ERROR; #else @@ -1060,7 +1060,7 @@ ngx_http_lua_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) if (sscf && sscf->ssl.ctx) { #ifdef LIBRESSL_VERSION_NUMBER ngx_log_error(NGX_LOG_EMERG, cf->log, 0, - "LibreSSL does not support " + "LibreSSL is not supported by " "ssl_session_store_by_lua*"); return NGX_CONF_ERROR; @@ -1083,7 +1083,7 @@ ngx_http_lua_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) if (sscf && sscf->ssl.ctx) { #ifdef LIBRESSL_VERSION_NUMBER ngx_log_error(NGX_LOG_EMERG, cf->log, 0, - "LibreSSL does not support " + "LibreSSL is not supported by " "ssl_session_fetch_by_lua*"); return NGX_CONF_ERROR; diff --git a/src/ngx_http_lua_regex.c b/src/ngx_http_lua_regex.c index 8f3373b4d5..9593575d7c 100644 --- a/src/ngx_http_lua_regex.c +++ b/src/ngx_http_lua_regex.c @@ -2043,7 +2043,7 @@ ngx_http_lua_regex_compile(ngx_http_lua_regex_compile_t *rc) if ((size_t) erroff == rc->pattern.len) { rc->err.len = ngx_snprintf(rc->err.data, rc->err.len, "pcre_compile() failed: %s in \"%V\"", - errstr, &rc->pattern) + errstr, &rc->pattern) - rc->err.data; } else { diff --git a/src/ngx_http_lua_shdict.c b/src/ngx_http_lua_shdict.c index b017bea658..0cda3b7b18 100644 --- a/src/ngx_http_lua_shdict.c +++ b/src/ngx_http_lua_shdict.c @@ -44,7 +44,7 @@ static int ngx_http_lua_shdict_llen(lua_State *L); static ngx_inline ngx_shm_zone_t *ngx_http_lua_shdict_get_zone(lua_State *L, - int index); + int index); #define NGX_HTTP_LUA_SHDICT_ADD 0x0001 diff --git a/src/ngx_http_lua_util.c b/src/ngx_http_lua_util.c index 47768c003b..219bff6fd3 100644 --- a/src/ngx_http_lua_util.c +++ b/src/ngx_http_lua_util.c @@ -2588,9 +2588,9 @@ ngx_http_lua_process_args_option(ngx_http_request_t *r, lua_State *L, if (lua_isboolean(L, -1)) { if (lua_toboolean(L, -1)) { if (total_escape) { - p = (u_char *) ngx_http_lua_escape_uri(p, key, - key_len, - NGX_ESCAPE_URI_COMPONENT); + p = (u_char *) + ngx_http_lua_escape_uri(p, key, key_len, + NGX_ESCAPE_URI_COMPONENT); } else { dd("shortcut: no escape required"); @@ -3371,7 +3371,7 @@ ngx_http_lua_check_broken_connection(ngx_http_request_t *r, ngx_event_t *ev) char buf[1]; ngx_err_t err; ngx_int_t event; - ngx_connection_t *c; + ngx_connection_t *c; ngx_log_debug2(NGX_LOG_DEBUG_HTTP, ev->log, 0, "http lua check client, write event:%d, \"%V\"", From 54305d4846f33c40e9beacf57b3c28bca79a38ff Mon Sep 17 00:00:00 2001 From: Thibault Charbonnier Date: Tue, 30 Jul 2019 13:19:32 -0700 Subject: [PATCH 4/5] tweak: updated the debug log in 'ngx_http_lua_socket_tcp_conn_op_ctx_cleanup()' to align with the meta_lua module. --- src/ngx_http_lua_socket_tcp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ngx_http_lua_socket_tcp.c b/src/ngx_http_lua_socket_tcp.c index 42abb7e4f2..3173ab1b94 100644 --- a/src/ngx_http_lua_socket_tcp.c +++ b/src/ngx_http_lua_socket_tcp.c @@ -4012,9 +4012,11 @@ ngx_http_lua_socket_tcp_conn_op_ctx_cleanup(void *data) ngx_http_lua_socket_tcp_conn_op_ctx_t *conn_op_ctx = data; u = conn_op_ctx->u; - ngx_log_debug1(NGX_LOG_DEBUG_HTTP, u->request->connection->log, 0, - "cleanup lua tcp socket conn_op_ctx: \"%V\"", - &u->request->uri); + + ngx_log_debug3(NGX_LOG_DEBUG_HTTP, u->request->connection->log, 0, + "cleanup lua tcp socket conn_op_ctx: %p, u: %p, " + "request: \"%V\"", + conn_op_ctx, u, &u->request->uri); ngx_queue_insert_head(&u->socket_pool->cache_connect_op, &conn_op_ctx->queue); From fc790d0660db79df9b8a2f38cf7ac38765d7c0b8 Mon Sep 17 00:00:00 2001 From: Thibault Charbonnier Date: Tue, 30 Jul 2019 14:24:23 -0700 Subject: [PATCH 5/5] bugfix: added missing arguments to an 'ngx_log_error()' call in ngx_http_lua_pipe.c. --- src/ngx_http_lua_pipe.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ngx_http_lua_pipe.c b/src/ngx_http_lua_pipe.c index f9ae6cd455..c525e0b9b8 100644 --- a/src/ngx_http_lua_pipe.c +++ b/src/ngx_http_lua_pipe.c @@ -1133,7 +1133,8 @@ ngx_http_lua_ffi_pipe_proc_destroy(ngx_http_lua_ffi_pipe_proc_t *proc) if (kill(proc->_pid, SIGKILL) == -1) { if (ngx_errno != ESRCH) { ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, ngx_errno, - "lua pipe failed to kill process:%p pid:%P"); + "lua pipe failed to kill process:%p pid:%P", + proc, proc->_pid); } } }