From 07d886b43e723999ba41420f0987710928128581 Mon Sep 17 00:00:00 2001 From: lijunlong Date: Sun, 12 Sep 2021 19:21:38 +0800 Subject: [PATCH 1/3] style: fixed some of the code style issues and add style check for ci. --- .travis.yml | 4 +++- src/ngx_http_lua_bodyfilterby.c | 6 ++++-- src/ngx_http_lua_module.c | 3 ++- src/ngx_http_lua_pipe.c | 2 +- src/ngx_http_lua_ssl_session_fetchby.c | 2 +- src/ngx_http_lua_ssl_session_storeby.c | 2 +- src/ngx_http_lua_util.c | 12 +++++++++--- src/ngx_http_lua_worker_thread.c | 2 +- 8 files changed, 22 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5b3e09be3b..b4082f30a2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -96,6 +96,9 @@ before_script: - mysql -uroot -e 'create database ngx_test; grant all on ngx_test.* to "ngx_test"@"%" identified by "ngx_test"; flush privileges;' script: + - export PATH=$PWD/work/nginx/sbin:$PWD/openresty-devel-utils:$PATH + - ngx-releng > check.txt || true + - lines=`wc -l check.txt | awk '{print $1}'`; if [ $lines -gt 13 ]; then cat check.txt; exit 1; fi - sudo iptables -I OUTPUT 1 -p udp --dport 10086 -j REJECT - sudo iptables -I OUTPUT -p tcp --dst 127.0.0.2 --dport 12345 -j DROP - sudo iptables -I OUTPUT -p udp --dst 127.0.0.2 --dport 12345 -j DROP @@ -123,7 +126,6 @@ script: - make -j$JOBS > build.log 2>&1 || (cat build.log && exit 1) - sudo make PATH=$PATH install_sw > build.log 2>&1 || (cat build.log && exit 1) - cd .. - - export PATH=$PWD/work/nginx/sbin:$PWD/openresty-devel-utils:$PATH - export NGX_BUILD_CC=$CC - sh util/build.sh $NGINX_VERSION > build.log 2>&1 || (cat build.log && exit 1) - nginx -V diff --git a/src/ngx_http_lua_bodyfilterby.c b/src/ngx_http_lua_bodyfilterby.c index a85de31689..902488911e 100644 --- a/src/ngx_http_lua_bodyfilterby.c +++ b/src/ngx_http_lua_bodyfilterby.c @@ -272,7 +272,8 @@ ngx_http_lua_body_filter(ngx_http_request_t *r, ngx_chain_t *in) } if (in != NULL - && ngx_chain_add_copy(r->pool, &ctx->filter_in_bufs, in) != NGX_OK) { + && ngx_chain_add_copy(r->pool, &ctx->filter_in_bufs, in) != NGX_OK) + { return NGX_ERROR; } @@ -301,7 +302,8 @@ ngx_http_lua_body_filter(ngx_http_request_t *r, ngx_chain_t *in) if (rc != NGX_OK && ctx->filter_busy_bufs != NULL && (r->connection->buffered - & (NGX_HTTP_LOWLEVEL_BUFFERED | NGX_LOWLEVEL_BUFFERED))) { + & (NGX_HTTP_LOWLEVEL_BUFFERED | NGX_LOWLEVEL_BUFFERED))) + { ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "waiting body filter busy buffer to be sent"); return NGX_AGAIN; diff --git a/src/ngx_http_lua_module.c b/src/ngx_http_lua_module.c index 79c7e35766..baf8ad4a40 100644 --- a/src/ngx_http_lua_module.c +++ b/src/ngx_http_lua_module.c @@ -1459,7 +1459,8 @@ ngx_http_lua_set_ssl(ngx_conf_t *cf, ngx_http_lua_loc_conf_t *llcf) #if (nginx_version >= 1019004) if (ngx_ssl_conf_commands(cf, llcf->ssl, llcf->ssl_conf_commands) - != NGX_OK) { + != NGX_OK) + { return NGX_ERROR; } #endif diff --git a/src/ngx_http_lua_pipe.c b/src/ngx_http_lua_pipe.c index b610045bb0..9ea0ba1c41 100644 --- a/src/ngx_http_lua_pipe.c +++ b/src/ngx_http_lua_pipe.c @@ -550,8 +550,8 @@ static int ngx_http_lua_execvpe(const char *program, char * const argv[], char * const envp[]) { + int rc; char **saved = environ; - int rc; environ = (char **) envp; rc = execvp(program, argv); diff --git a/src/ngx_http_lua_ssl_session_fetchby.c b/src/ngx_http_lua_ssl_session_fetchby.c index 8d8c42b213..6584e6ab58 100644 --- a/src/ngx_http_lua_ssl_session_fetchby.c +++ b/src/ngx_http_lua_ssl_session_fetchby.c @@ -450,7 +450,7 @@ ngx_http_lua_log_ssl_sess_fetch_error(ngx_log_t *log, u_char *buf, size_t len) } if (c->listening && c->listening->addr_text.len) { - p = ngx_snprintf(buf, len, ", server: %V", \ + p = ngx_snprintf(buf, len, ", server: %V", &c->listening->addr_text); buf = p; } diff --git a/src/ngx_http_lua_ssl_session_storeby.c b/src/ngx_http_lua_ssl_session_storeby.c index 2cfc8f6559..0654d93715 100644 --- a/src/ngx_http_lua_ssl_session_storeby.c +++ b/src/ngx_http_lua_ssl_session_storeby.c @@ -336,7 +336,7 @@ ngx_http_lua_log_ssl_sess_store_error(ngx_log_t *log, u_char *buf, size_t len) } if (c->listening && c->listening->addr_text.len) { - p = ngx_snprintf(buf, len, ", server: %V", \ + p = ngx_snprintf(buf, len, ", server: %V", &c->listening->addr_text); buf = p; } diff --git a/src/ngx_http_lua_util.c b/src/ngx_http_lua_util.c index 1a04bf025a..38e1b68384 100644 --- a/src/ngx_http_lua_util.c +++ b/src/ngx_http_lua_util.c @@ -376,8 +376,10 @@ ngx_http_lua_new_thread(ngx_http_request_t *r, lua_State *L, int *ref) if (!lua_isnil(L, -1) && !lua_isnil(L, -2)) { n++; } + lua_pop(L, 1); } + lua_pop(L, 1); ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, @@ -2199,6 +2201,7 @@ ngx_http_lua_escape_uri(u_char *dst, u_char *src, size_t size, ngx_uint_t type) return (uintptr_t) dst; } + static int ngx_http_lua_util_hex2int(char xdigit) { @@ -2214,14 +2217,15 @@ ngx_http_lua_util_hex2int(char xdigit) return -1; } + /* XXX we also decode '+' to ' ' */ void ngx_http_lua_unescape_uri(u_char **dst, u_char **src, size_t size, ngx_uint_t type) { - u_char *d = *dst, *s = *src, *de = (*dst+size); - int isuri = type & NGX_UNESCAPE_URI; - int isredirect = type & NGX_UNESCAPE_REDIRECT; + u_char *d = *dst, *s = *src, *de = (*dst + size); + int isuri = type & NGX_UNESCAPE_URI; + int isredirect = type & NGX_UNESCAPE_REDIRECT; while (size--) { u_char curr = *s++; @@ -2245,10 +2249,12 @@ ngx_http_lua_unescape_uri(u_char **dst, u_char **src, size_t size, if ((isuri || isredirect) && ch == '?') { *d++ = ch; break; + } else if (isredirect && (ch <= '%' || ch >= 0x7f)) { *d++ = '%'; continue; } + *d++ = ch; s += 2; size -= 2; diff --git a/src/ngx_http_lua_worker_thread.c b/src/ngx_http_lua_worker_thread.c index 92bb77d4cd..080de53776 100644 --- a/src/ngx_http_lua_worker_thread.c +++ b/src/ngx_http_lua_worker_thread.c @@ -153,7 +153,7 @@ ngx_http_lua_free_task_ctx(ngx_http_lua_task_ctx_t *ctx) static int ngx_http_lua_xcopy(lua_State *from, lua_State *to, int idx, - const int allow_nil) + const int allow_nil) { size_t len = 0; const char *str; From 0245bffb8275f58d9b17495aa66d480cea6ca292 Mon Sep 17 00:00:00 2001 From: lijunlong Date: Sun, 12 Sep 2021 19:31:34 +0800 Subject: [PATCH 2/3] tests: openresty-devel-utils repo change to master_on branch. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b4082f30a2..121248cd9b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -70,7 +70,7 @@ install: - git clone https://github.com/openresty/test-nginx.git - git clone https://github.com/openresty/openresty.git ../openresty - git clone https://github.com/openresty/no-pool-nginx.git ../no-pool-nginx - - git clone https://github.com/openresty/openresty-devel-utils.git + - git clone -b master_on https://github.com/openresty/openresty-devel-utils.git - git clone https://github.com/openresty/mockeagain.git - git clone https://github.com/openresty/lua-cjson.git lua-cjson - git clone https://github.com/openresty/lua-upstream-nginx-module.git ../lua-upstream-nginx-module From 2c3382853526ccb22debfe694e21a2b70d772b90 Mon Sep 17 00:00:00 2001 From: lijunlong Date: Mon, 13 Sep 2021 07:47:02 +0800 Subject: [PATCH 3/3] tests: revert the change of .travis.yml. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 121248cd9b..b4082f30a2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -70,7 +70,7 @@ install: - git clone https://github.com/openresty/test-nginx.git - git clone https://github.com/openresty/openresty.git ../openresty - git clone https://github.com/openresty/no-pool-nginx.git ../no-pool-nginx - - git clone -b master_on https://github.com/openresty/openresty-devel-utils.git + - git clone https://github.com/openresty/openresty-devel-utils.git - git clone https://github.com/openresty/mockeagain.git - git clone https://github.com/openresty/lua-cjson.git lua-cjson - git clone https://github.com/openresty/lua-upstream-nginx-module.git ../lua-upstream-nginx-module