From 5115c24f94eab7d3be8ad11e59c82494c05ce3a2 Mon Sep 17 00:00:00 2001 From: Jakub Jirutka Date: Thu, 27 Apr 2017 00:21:50 +0200 Subject: main/nginx: upgrade to 1.12.0 Upgraded modules: * lua-nginx-module to 0.10.8 * nchan to 1.1.4 * nginx-rtmp-module to 1.1.11 --- main/nginx/APKBUILD | 52 ++++-- main/nginx/echo-nginx-module~fix-nginx-1.12.patch | 211 +++++++++++++++++++++ main/nginx/ipv6.patch | 42 ----- main/nginx/lua-nginx-module~fix-libressl.patch | 26 +++ main/nginx/lua-nginx-module~fix-nginx-1.12.patch | 215 ++++++++++++++++++++++ 5 files changed, 490 insertions(+), 56 deletions(-) create mode 100644 main/nginx/echo-nginx-module~fix-nginx-1.12.patch delete mode 100644 main/nginx/ipv6.patch create mode 100644 main/nginx/lua-nginx-module~fix-libressl.patch create mode 100644 main/nginx/lua-nginx-module~fix-nginx-1.12.patch (limited to 'main/nginx') diff --git a/main/nginx/APKBUILD b/main/nginx/APKBUILD index 9c6301f331..596a1d60d5 100644 --- a/main/nginx/APKBUILD +++ b/main/nginx/APKBUILD @@ -4,8 +4,8 @@ # Contributor: Jakub Jirutka pkgname=nginx -pkgver=1.10.3 -pkgrel=5 +pkgver=1.12.0 +pkgrel=0 pkgdesc="HTTP and reverse proxy server (stable version)" url="http://www.nginx.org/en" arch="all" @@ -39,14 +39,14 @@ _http_headers_more_dir="$srcdir/$_http_headers_more_name-$_http_headers_more_ver _http_headers_more_so="ngx_http_headers_more_filter_module.so" _http_lua_name=lua-nginx-module -_http_lua_ver=0.10.7 +_http_lua_ver=0.10.8 _http_lua_url="https://github.com/openresty/lua-nginx-module" _http_lua_dir="$srcdir/$_http_lua_name-$_http_lua_ver" _http_lua_depends="$pkgname-mod-devel-kit" _http_lua_provides="$pkgname-lua" # for backward compatibility _http_nchan_name=nchan -_http_nchan_ver=1.1.0 +_http_nchan_ver=1.1.4 _http_nchan_url="https://github.com/slact/nchan" _http_nchan_dir="$srcdir/$_http_nchan_name-$_http_nchan_ver" _http_nchan_so="ngx_nchan_module.so" @@ -58,7 +58,7 @@ _http_upload_progress_dir="$srcdir/$_http_upload_progress_name-$_http_upload_pro _http_upload_progress_so="ngx_http_uploadprogress_module.so" _rtmp_name=nginx-rtmp-module -_rtmp_ver=1.1.10 +_rtmp_ver=1.1.11 _rtmp_url="https://github.com/arut/nginx-rtmp-module" _rtmp_dir="$srcdir/$_rtmp_name-$_rtmp_ver" _rtmp_provides="$pkgname-rtmp" # for backward compatibility @@ -79,9 +79,12 @@ source="http://nginx.org/download/$pkgname-$pkgver.tar.gz $pkgname-tests-$_tests_hgrev.tar.gz::http://hg.nginx.org/nginx-tests/archive/$_tests_hgrev.tar.gz $_devel_kit_name-$_devel_kit_ver.tar.gz::$_devel_kit_url/archive/v$_devel_kit_ver.tar.gz $_http_echo_name-$_http_echo_ver.tar.gz::$_http_echo_url/archive/v$_http_echo_ver.tar.gz + $_http_echo_name~fix-nginx-1.12.patch $_http_fancyindex_name-$_http_fancyindex_ver.tar.gz::$_http_fancyindex_url/archive/v$_http_fancyindex_ver.tar.gz $_http_headers_more_name-$_http_headers_more_ver.tar.gz::$_http_headers_more_url/archive/v$_http_headers_more_ver.tar.gz $_http_lua_name-$_http_lua_ver.tar.gz::$_http_lua_url/archive/v$_http_lua_ver.tar.gz + $_http_lua_name~fix-nginx-1.12.patch + $_http_lua_name~fix-libressl.patch $_http_nchan_name-$_http_nchan_ver.tar.gz::$_http_nchan_url/archive/v$_http_nchan_ver.tar.gz $_http_upload_progress_name-$_http_upload_progress_ver.tar.gz::$_http_upload_progress_url/archive/v$_http_upload_progress_ver.tar.gz $_rtmp_name-$_rtmp_ver.tar.gz::$_rtmp_url/archive/v$_rtmp_ver.tar.gz @@ -89,7 +92,6 @@ source="http://nginx.org/download/$pkgname-$pkgver.tar.gz default.conf $pkgname.logrotate $pkgname.initd - ipv6.patch " builddir="$srcdir/$pkgname-$pkgver" @@ -107,6 +109,7 @@ _modules=" http-xslt-filter mail stream + stream-geoip devel-kit http-echo http-fancyindex @@ -120,6 +123,23 @@ for _m in $_modules; do done +prepare() { + local file; for file in $source; do + case $file in + *~*.patch) + msg $file + cd "$srcdir"/${file%%~*}-* + patch -p 1 -i "$srcdir/$file" + ;; + *.patch) + msg $file + cd "$builddir" + patch -p 1 -i "$srcdir/$file" + ;; + esac + done +} + build() { cd "$builddir" @@ -143,7 +163,6 @@ build() { --group=$_grp_ngx \ --with-threads \ --with-file-aio \ - --with-ipv6 \ \ --with-http_ssl_module \ --with-http_v2_module \ @@ -161,14 +180,17 @@ build() { --with-http_auth_request_module \ --with-http_random_index_module \ --with-http_secure_link_module \ + --with-http_degradation_module \ --with-http_slice_module \ --with-http_stub_status_module \ --with-http_perl_module=dynamic \ - --with-http_realip_module \ --with-mail=dynamic \ --with-mail_ssl_module \ --with-stream=dynamic \ --with-stream_ssl_module \ + --with-stream_realip_module \ + --with-stream_geoip_module=dynamic \ + --with-stream_ssl_preread_module \ \ --add-dynamic-module="$_devel_kit_dir" \ --add-dynamic-module="$_http_echo_dir" \ @@ -261,18 +283,20 @@ _module() { echo "load_module \"modules/$soname\";" > ./etc/nginx/modules/$name.conf } -sha512sums="25cddbe5c419700aeca41bff3be5b7c3accfb38ad846ec8d91d81ab7c15f10db719f02d9263edf1fa12f59805ff7001b62864dc2885370b24afeea1d7d2afbbf nginx-1.10.3.tar.gz +sha512sums="e2e930b61491d91090090d4716740895fc7812e8e266c427ac2b40c5a70493150e5c81e769c6b7563baf5f0e15b32fae8f2b11fd5699e468e1cc40706defb8ee nginx-1.12.0.tar.gz ca8be839aef71c537d6d3a79e2894f38790834d6310c6d15ad06900c7c2d7cf71a113847ab96ef9be0fbdfff3b7808e74dea427502b275cfd6c909550f9ba9ab nginx-tests-cdd44ff602db.tar.gz 558764c9be913a4f61d0e277d07bf3c272e1ce086b3fadb85b693a7e92805cd9fca4da7a8d29c96e53fc0d23b331327d3b2561ff61f19d2330e7d5d35ac7d614 ngx_devel_kit-0.3.0.tar.gz c455bee73cebd0752449472452d15614b9587ddd199263d366484ede890c4d108eacbbeaef31adc9dc7732b56ef2bfc73c0fef3366366db03a8ec3fdc27a985c echo-nginx-module-0.60.tar.gz +401f57ed73941619cdd41061bd92fffc00730e34cc647ea3c9345225723e9c7ebd72d9d15a703cffd93b0a99d458a05fe5efa7373ae24f41b35279285b5ca0fa echo-nginx-module~fix-nginx-1.12.patch ce0043ad4a2b638c5d99244d6caaa65ad142cea78884084a9aeca5a9593c68dbe508c9e4dd85dc5722eb63ef386612bffc48d4b6fc1487df244fbcb7a73bffe1 ngx-fancyindex-0.4.1.tar.gz e42582b45c3111de3940bbeb67ce161aca2d55adcfb00c61c12256fa0e36221d38723013f36edbcf6d1b520f8dfb49d4657df8a956e66d36e68425afad382bd1 headers-more-nginx-module-0.32.tar.gz -d060a13de4d01d77e6d6cd1635ecbb405330e4326b71b89341c1c128ee4182978a51d53355bc07c350e3c3a7df15325e3df380d9c3a98b2ff7d7efa18fa09b32 lua-nginx-module-0.10.7.tar.gz -bb3a9aec5e4c9f1c376126b4b07c2e5c6cddae3659a9218bd7b0dcaa5b0e1772036eea2c7e45bbb46f61a3a9090f0092fc93e91dbb57fc5b4e65eef6ba14fc23 nchan-1.1.0.tar.gz +ad621cec178eb37109f16ebc30dbab7b1ea344ac4b523ff1e6ad62364b8cf437488a89c593ca44b446b729a1c578e3a97685851847b4b16a147ac9eca8f23a2a lua-nginx-module-0.10.8.tar.gz +04f7d75ce15eba99be99a76d266903c17e48742ab4bf237b988bf84f00cdbf6510c3d4eee88a24620e56dc426220192df39f4736af157fdc4e4c50b4f1d794f2 lua-nginx-module~fix-nginx-1.12.patch +fd8bce0e7d69552267b8e405b07fc9323e25e06cceb8912a2d143952447a4299756e6a9a8a40f4eabe8b00fed475fd87ee4a982f5ad7449d59783e872c682451 lua-nginx-module~fix-libressl.patch +458bddfb27b8aa8a99a6324a600620531b2c71f035c10304868a1acb523a288ee6f90746dbe43cd8c476ed55ad01649a225a5ea73eedf3a199387fe2049c529e nchan-1.1.4.tar.gz c31c46344d49704389722325a041b9cd170fa290acefe92cfc572c07f711cd3039de78f28df48ca7dcb79b2e4bbe442580aaaf4d92883fd3a14bf41d66dd9d8c nginx-upload-progress-module-0.9.2.tar.gz -bcc0aee3308af7c61bf01a5530fcf1dae938e6778306f6e3eb5995e6d0529f43d33b7ee2acb813d5a39acc92e4853d207a01e8e41b766a6e0dd07aade60cd98f nginx-rtmp-module-1.1.10.tar.gz +e7c897265d1e93b06f7e46a653b113e24d2451e2112a7a6da415f130928437444a0346832fd9c10042397fea6120e4e44acc2bccf649ec30ca5bffbf985672e2 nginx-rtmp-module-1.1.11.tar.gz ac7e3153ab698b4cde077f0d5d7ac0a58897927eb36cf3b58cb01268ca0296f1d589c0a5b4f889b96b5b4a57bef05b17c59be59a9d7c4d7a3d3be58f101f7f41 nginx.conf 0907f69dc2d3dc1bad3a04fb6673f741f1a8be964e22b306ef9ae2f8e736e1f5733a8884bfe54f3553fff5132a0e5336716250f54272c3fec2177d6ba16986f3 default.conf 09b110693e3f4377349ccea3c43cb8199c8579ee351eae34283299be99fdf764b0c1bddd552e13e4d671b194501618b29c822e1ad53b34101a73a63954363dbb nginx.logrotate -1ea032cf88021ec8aa1401d284ea738364511cdb9f8c01670deb8e59aae570f5bbe17f0cbab73c0e08d6b342a621b6a9c014832168ed41f6028ecfa4211b60cf nginx.initd -68d64a84568ec2df0366925ab282a05ebe21a85044b6c7844a47573cfd8cc8ed119cc772358bc3fff36e2d4fdf583a730592825f5f98632993ca86d1f8438d5f ipv6.patch" +1ea032cf88021ec8aa1401d284ea738364511cdb9f8c01670deb8e59aae570f5bbe17f0cbab73c0e08d6b342a621b6a9c014832168ed41f6028ecfa4211b60cf nginx.initd" diff --git a/main/nginx/echo-nginx-module~fix-nginx-1.12.patch b/main/nginx/echo-nginx-module~fix-nginx-1.12.patch new file mode 100644 index 0000000000..9f1af70f07 --- /dev/null +++ b/main/nginx/echo-nginx-module~fix-nginx-1.12.patch @@ -0,0 +1,211 @@ +From 7740e11558b530b66b469c657576f5280b7cdb1b Mon Sep 17 00:00:00 2001 +From: Andrei Belov +Date: Wed, 22 Mar 2017 08:43:30 +0300 +Subject: [PATCH] feature: nginx 1.11.11+ can now build with this module. + +Note: nginx 1.11.11+ are still not an officially supported target yet. +More work needed. + +Closes openresty/echo-nginx-module#64 + +See also: +http://hg.nginx.org/nginx/rev/e662cbf1b932 + +Signed-off-by: Yichun Zhang (agentzh) + +Patch-Origin: Upstream's repository, master branch. +--- + src/ngx_http_echo_module.c | 13 +++++++++ + src/ngx_http_echo_module.h | 4 +++ + src/ngx_http_echo_request_info.c | 62 ++++++++++++++++++++++++++++++++++++++++ + src/ngx_http_echo_request_info.h | 3 ++ + valgrind.suppress | 10 +++++++ + 5 files changed, 92 insertions(+) + +diff --git a/src/ngx_http_echo_module.c b/src/ngx_http_echo_module.c +index ae70479..8d736d7 100644 +--- a/src/ngx_http_echo_module.c ++++ b/src/ngx_http_echo_module.c +@@ -632,6 +632,9 @@ ngx_http_echo_echo_exec(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) + static void * + ngx_http_echo_create_main_conf(ngx_conf_t *cf) + { ++#if nginx_version >= 1011011 ++ ngx_pool_cleanup_t *cln; ++#endif + ngx_http_echo_main_conf_t *emcf; + + emcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_echo_main_conf_t)); +@@ -643,6 +646,16 @@ ngx_http_echo_create_main_conf(ngx_conf_t *cf) + * hmcf->requires_filter = 0; + */ + ++#if nginx_version >= 1011011 ++ cln = ngx_pool_cleanup_add(cf->pool, 0); ++ if (cln == NULL) { ++ return NULL; ++ } ++ ++ cln->data = emcf; ++ cln->handler = ngx_http_echo_request_headers_cleanup; ++#endif ++ + return emcf; + } + +diff --git a/src/ngx_http_echo_module.h b/src/ngx_http_echo_module.h +index 2d212c3..ce0a305 100644 +--- a/src/ngx_http_echo_module.h ++++ b/src/ngx_http_echo_module.h +@@ -92,6 +92,10 @@ typedef struct { + + typedef struct { + ngx_int_t requires_filter; ++#if nginx_version >= 1011011 ++ ngx_buf_t **busy_buf_ptrs; ++ ngx_int_t busy_buf_ptr_count; ++#endif + } ngx_http_echo_main_conf_t; + + +diff --git a/src/ngx_http_echo_request_info.c b/src/ngx_http_echo_request_info.c +index d28ec4d..7dd3683 100644 +--- a/src/ngx_http_echo_request_info.c ++++ b/src/ngx_http_echo_request_info.c +@@ -17,6 +17,9 @@ + + + static void ngx_http_echo_post_read_request_body(ngx_http_request_t *r); ++#if nginx_version >= 1011011 ++void ngx_http_echo_request_headers_cleanup(void *data); ++#endif + + + ngx_int_t +@@ -179,6 +182,11 @@ ngx_http_echo_client_request_headers_variable(ngx_http_request_t *r, + ngx_int_t i, j; + ngx_buf_t *b, *first = NULL; + unsigned found; ++#if nginx_version >= 1011011 ++ ngx_buf_t **bb; ++ ngx_chain_t *cl; ++ ngx_http_echo_main_conf_t *emcf; ++#endif + ngx_connection_t *c; + ngx_http_request_t *mr; + ngx_http_connection_t *hc; +@@ -195,6 +203,10 @@ ngx_http_echo_client_request_headers_variable(ngx_http_request_t *r, + } + #endif + ++#if nginx_version >= 1011011 ++ emcf = ngx_http_get_module_main_conf(r, ngx_http_echo_module); ++#endif ++ + size = 0; + b = c->buffer; + +@@ -215,8 +227,35 @@ ngx_http_echo_client_request_headers_variable(ngx_http_request_t *r, + + if (hc->nbusy) { + b = NULL; ++ ++#if nginx_version >= 1011011 ++ if (hc->nbusy > emcf->busy_buf_ptr_count) { ++ if (emcf->busy_buf_ptrs) { ++ ngx_free(emcf->busy_buf_ptrs); ++ } ++ ++ emcf->busy_buf_ptrs = ngx_alloc(hc->nbusy * sizeof(ngx_buf_t *), ++ r->connection->log); ++ ++ if (emcf->busy_buf_ptrs == NULL) { ++ return NGX_ERROR; ++ } ++ ++ emcf->busy_buf_ptr_count = hc->nbusy; ++ } ++ ++ bb = emcf->busy_buf_ptrs; ++ for (cl = hc->busy; cl; cl = cl->next) { ++ *bb++ = cl->buf; ++ } ++ ++ bb = emcf->busy_buf_ptrs; ++ for (i = hc->nbusy; i > 0; i--) { ++ b = bb[i - 1]; ++#else + for (i = 0; i < hc->nbusy; i++) { + b = hc->busy[i]; ++#endif + + if (first == NULL) { + if (mr->request_line.data >= b->pos +@@ -280,8 +319,15 @@ ngx_http_echo_client_request_headers_variable(ngx_http_request_t *r, + } + + if (hc->nbusy) { ++ ++#if nginx_version >= 1011011 ++ bb = emcf->busy_buf_ptrs; ++ for (i = hc->nbusy; i > 0; i--) { ++ b = bb[i - 1]; ++#else + for (i = 0; i < hc->nbusy; i++) { + b = hc->busy[i]; ++#endif + + if (!found) { + if (b != first) { +@@ -457,4 +503,20 @@ ngx_http_echo_response_status_variable(ngx_http_request_t *r, + return NGX_OK; + } + ++ ++#if nginx_version >= 1011011 ++void ++ngx_http_echo_request_headers_cleanup(void *data) ++{ ++ ngx_http_echo_main_conf_t *emcf; ++ ++ emcf = (ngx_http_echo_main_conf_t *) data; ++ ++ if (emcf->busy_buf_ptrs) { ++ ngx_free(emcf->busy_buf_ptrs); ++ emcf->busy_buf_ptrs = NULL; ++ } ++} ++#endif ++ + /* vi:set ft=c ts=4 sw=4 et fdm=marker: */ +diff --git a/src/ngx_http_echo_request_info.h b/src/ngx_http_echo_request_info.h +index 3b3713b..aa5730b 100644 +--- a/src/ngx_http_echo_request_info.h ++++ b/src/ngx_http_echo_request_info.h +@@ -29,5 +29,8 @@ ngx_int_t ngx_http_echo_request_uri_variable(ngx_http_request_t *r, + ngx_int_t ngx_http_echo_response_status_variable(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t data); + ++#if nginx_version >= 1011011 ++void ngx_http_echo_request_headers_cleanup(void *data); ++#endif + + #endif /* ECHO_REQUEST_INFO_H */ +diff --git a/valgrind.suppress b/valgrind.suppress +index 0f8e871..d4bfe63 100644 +--- a/valgrind.suppress ++++ b/valgrind.suppress +@@ -36,3 +36,13 @@ + fun:do_preload + fun:dl_main + } ++{ ++ ++ Memcheck:Leak ++ match-leak-kinds: definite ++ fun:malloc ++ fun:ngx_alloc ++ fun:ngx_set_environment ++ fun:ngx_single_process_cycle ++ fun:main ++} diff --git a/main/nginx/ipv6.patch b/main/nginx/ipv6.patch deleted file mode 100644 index 9b05f8ff83..0000000000 --- a/main/nginx/ipv6.patch +++ /dev/null @@ -1,42 +0,0 @@ ---- a/src/http/ngx_http_core_module.c -+++ b/src/http/ngx_http_core_module.c -@@ -2442,7 +2442,11 @@ - ngx_uint_t i; - ngx_conf_t pcf; - ngx_http_module_t *module; -+#if (NGX_HAVE_INET6) -+ struct sockaddr_in6 *sin6; -+#else - struct sockaddr_in *sin; -+#endif - ngx_http_conf_ctx_t *ctx, *http_ctx; - ngx_http_listen_opt_t lsopt; - ngx_http_core_srv_conf_t *cscf, **cscfp; -@@ -2526,6 +2530,19 @@ - if (rv == NGX_CONF_OK && !cscf->listen) { - ngx_memzero(&lsopt, sizeof(ngx_http_listen_opt_t)); - -+#if (NGX_HAVE_INET6) -+ sin6 = &lsopt.u.sockaddr_in6; -+ -+ sin6->sin6_family = AF_INET6; -+#if (NGX_WIN32) -+ sin6->sin6_port = htons(80); -+#else -+ sin6->sin6_port = htons((getuid() == 0) ? 80 : 8000); -+#endif -+ sin6->sin6_addr = in6addr_any; -+ -+ lsopt.socklen = sizeof(struct sockaddr_in6); -+#else - sin = &lsopt.u.sockaddr_in; - - sin->sin_family = AF_INET; -@@ -2537,6 +2554,7 @@ - sin->sin_addr.s_addr = INADDR_ANY; - - lsopt.socklen = sizeof(struct sockaddr_in); -+#endif - - lsopt.backlog = NGX_LISTEN_BACKLOG; - lsopt.rcvbuf = -1; diff --git a/main/nginx/lua-nginx-module~fix-libressl.patch b/main/nginx/lua-nginx-module~fix-libressl.patch new file mode 100644 index 0000000000..21a73c1050 --- /dev/null +++ b/main/nginx/lua-nginx-module~fix-libressl.patch @@ -0,0 +1,26 @@ +From 7206c8f6fe10136e458d4b3c7ae2b696bd4c8983 Mon Sep 17 00:00:00 2001 +From: Alessandro Ghedini +Date: Thu, 12 May 2016 13:17:52 +0100 +Subject: [PATCH 3/6] bugfix: ssl: do not set tlsext_status_expected flag + +In OpenSSL 1.1.0 the SSL struct was made opaque, and setting this +flag manually is not required anyway since OpenSSL already does that +automatically when ngx_http_lua_ssl_empty_status_callback() returns +"OK" (which is always), and an OCSP response has been set. + +Upstream-Issue: https://github.com/openresty/lua-nginx-module/pull/761 +--- + src/ngx_http_lua_ssl_ocsp.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/src/ngx_http_lua_ssl_ocsp.c b/src/ngx_http_lua_ssl_ocsp.c +index 3904aa8..31b4f24 100644 +--- a/src/ngx_http_lua_ssl_ocsp.c ++++ b/src/ngx_http_lua_ssl_ocsp.c +@@ -490,7 +490,6 @@ ngx_http_lua_ffi_ssl_set_ocsp_status_resp(ngx_http_request_t *r, + + dd("set ocsp resp: resp_len=%d", (int) resp_len); + (void) SSL_set_tlsext_status_ocsp_resp(ssl_conn, p, resp_len); +- ssl_conn->tlsext_status_expected = 1; + + return NGX_OK; diff --git a/main/nginx/lua-nginx-module~fix-nginx-1.12.patch b/main/nginx/lua-nginx-module~fix-nginx-1.12.patch new file mode 100644 index 0000000000..d81669716b --- /dev/null +++ b/main/nginx/lua-nginx-module~fix-nginx-1.12.patch @@ -0,0 +1,215 @@ +From 0459a285ca0159d45e73da8bd1164edb5c57cde3 Mon Sep 17 00:00:00 2001 +From: Andrei Belov +Date: Wed, 22 Mar 2017 07:50:57 +0300 +Subject: [PATCH] feature: nginx 1.11.11+ can now build with this module. + +Note: nginx 1.11.11+ are still not an officially supported target yet. +More work needed. + +Closes openresty/lua-nginx-module#1016 + +See also: http://hg.nginx.org/nginx/rev/e662cbf1b932 + +Patch-Origin: Upstream's repository, master branch. +--- + src/ngx_http_lua_common.h | 6 ++++ + src/ngx_http_lua_headers.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++ + src/ngx_http_lua_headers.h | 3 ++ + src/ngx_http_lua_module.c | 13 ++++++++- + 4 files changed, 89 insertions(+), 1 deletion(-) + +diff --git a/src/ngx_http_lua_common.h b/src/ngx_http_lua_common.h +index 079a4dc..f37d776 100644 +--- a/src/ngx_http_lua_common.h ++++ b/src/ngx_http_lua_common.h +@@ -199,6 +199,12 @@ struct ngx_http_lua_main_conf_s { + of reqeusts */ + ngx_uint_t malloc_trim_req_count; + ++#if nginx_version >= 1011011 ++ /* the following 2 fields are only used by ngx.req.raw_headers() for now */ ++ ngx_buf_t **busy_buf_ptrs; ++ ngx_int_t busy_buf_ptr_count; ++#endif ++ + unsigned requires_header_filter:1; + unsigned requires_body_filter:1; + unsigned requires_capture_filter:1; +diff --git a/src/ngx_http_lua_headers.c b/src/ngx_http_lua_headers.c +index 2392598..6700ce8 100644 +--- a/src/ngx_http_lua_headers.c ++++ b/src/ngx_http_lua_headers.c +@@ -26,6 +26,9 @@ static int ngx_http_lua_ngx_req_get_headers(lua_State *L); + static int ngx_http_lua_ngx_req_header_clear(lua_State *L); + static int ngx_http_lua_ngx_req_header_set(lua_State *L); + static int ngx_http_lua_ngx_resp_get_headers(lua_State *L); ++#if nginx_version >= 1011011 ++void ngx_http_lua_ngx_raw_header_cleanup(void *data); ++#endif + + + static int +@@ -77,6 +80,11 @@ ngx_http_lua_ngx_req_raw_header(lua_State *L) + size_t size; + ngx_buf_t *b, *first = NULL; + ngx_int_t i, j; ++#if nginx_version >= 1011011 ++ ngx_buf_t **bb; ++ ngx_chain_t *cl; ++ ngx_http_lua_main_conf_t *lmcf; ++#endif + ngx_connection_t *c; + ngx_http_request_t *r, *mr; + ngx_http_connection_t *hc; +@@ -93,6 +101,10 @@ ngx_http_lua_ngx_req_raw_header(lua_State *L) + return luaL_error(L, "no request object found"); + } + ++#if nginx_version >= 1011011 ++ lmcf = ngx_http_get_module_main_conf(r, ngx_http_lua_module); ++#endif ++ + ngx_http_lua_check_fake_request(L, r); + + mr = r->main; +@@ -109,8 +121,13 @@ ngx_http_lua_ngx_req_raw_header(lua_State *L) + dd("hc->nbusy: %d", (int) hc->nbusy); + + if (hc->nbusy) { ++#if nginx_version >= 1011011 ++ dd("hc->busy: %p %p %p %p", hc->busy->buf->start, hc->busy->buf->pos, ++ hc->busy->buf->last, hc->busy->buf->end); ++#else + dd("hc->busy: %p %p %p %p", hc->busy[0]->start, hc->busy[0]->pos, + hc->busy[0]->last, hc->busy[0]->end); ++#endif + } + + dd("request line: %p %p", mr->request_line.data, +@@ -146,9 +163,37 @@ ngx_http_lua_ngx_req_raw_header(lua_State *L) + dd("size: %d", (int) size); + + if (hc->nbusy) { ++#if nginx_version >= 1011011 ++ if (hc->nbusy > lmcf->busy_buf_ptr_count) { ++ if (lmcf->busy_buf_ptrs) { ++ ngx_free(lmcf->busy_buf_ptrs); ++ } ++ ++ lmcf->busy_buf_ptrs = ngx_alloc(hc->nbusy * sizeof(ngx_buf_t *), ++ r->connection->log); ++ ++ if (lmcf->busy_buf_ptrs == NULL) { ++ return luaL_error(L, "no memory"); ++ } ++ ++ lmcf->busy_buf_ptr_count = hc->nbusy; ++ } ++ ++ bb = lmcf->busy_buf_ptrs; ++ for (cl = hc->busy; cl; cl = cl->next) { ++ *bb++ = cl->buf; ++ } ++#endif + b = NULL; ++ ++#if nginx_version >= 1011011 ++ bb = lmcf->busy_buf_ptrs; ++ for (i = hc->nbusy; i > 0; i--) { ++ b = bb[i - 1]; ++#else + for (i = 0; i < hc->nbusy; i++) { + b = hc->busy[i]; ++#endif + + dd("busy buf: %d: [%.*s]", (int) i, (int) (b->pos - b->start), + b->start); +@@ -223,8 +268,15 @@ ngx_http_lua_ngx_req_raw_header(lua_State *L) + } + + if (hc->nbusy) { ++ ++#if nginx_version >= 1011011 ++ bb = lmcf->busy_buf_ptrs; ++ for (i = hc->nbusy - 1; i >= 0; i--) { ++ b = bb[i]; ++#else + for (i = 0; i < hc->nbusy; i++) { + b = hc->busy[i]; ++#endif + + if (!found) { + if (b != first) { +@@ -1431,4 +1483,20 @@ ngx_http_lua_ffi_get_resp_header(ngx_http_request_t *r, + #endif /* NGX_LUA_NO_FFI_API */ + + ++#if nginx_version >= 1011011 ++void ++ngx_http_lua_ngx_raw_header_cleanup(void *data) ++{ ++ ngx_http_lua_main_conf_t *lmcf; ++ ++ lmcf = (ngx_http_lua_main_conf_t *) data; ++ ++ if (lmcf->busy_buf_ptrs) { ++ ngx_free(lmcf->busy_buf_ptrs); ++ lmcf->busy_buf_ptrs = NULL; ++ } ++} ++#endif ++ ++ + /* vi:set ft=c ts=4 sw=4 et fdm=marker: */ +diff --git a/src/ngx_http_lua_headers.h b/src/ngx_http_lua_headers.h +index 39f1114..ee4d21c 100644 +--- a/src/ngx_http_lua_headers.h ++++ b/src/ngx_http_lua_headers.h +@@ -15,6 +15,9 @@ + void ngx_http_lua_inject_resp_header_api(lua_State *L); + void ngx_http_lua_inject_req_header_api(lua_State *L); + void ngx_http_lua_create_headers_metatable(ngx_log_t *log, lua_State *L); ++#if nginx_version >= 1011011 ++void ngx_http_lua_ngx_raw_header_cleanup(void *data); ++#endif + + + #endif /* _NGX_HTTP_LUA_HEADERS_H_INCLUDED_ */ +diff --git a/src/ngx_http_lua_module.c b/src/ngx_http_lua_module.c +index 3dc2817..875f933 100644 +--- a/src/ngx_http_lua_module.c ++++ b/src/ngx_http_lua_module.c +@@ -28,6 +28,7 @@ + #include "ngx_http_lua_ssl_certby.h" + #include "ngx_http_lua_ssl_session_storeby.h" + #include "ngx_http_lua_ssl_session_fetchby.h" ++#include "ngx_http_lua_headers.h" + + + static void *ngx_http_lua_create_main_conf(ngx_conf_t *cf); +@@ -624,7 +625,7 @@ ngx_http_lua_init(ngx_conf_t *cf) + volatile ngx_cycle_t *saved_cycle; + ngx_http_core_main_conf_t *cmcf; + ngx_http_lua_main_conf_t *lmcf; +-#ifndef NGX_LUA_NO_FFI_API ++#if !defined(NGX_LUA_NO_FFI_API) || nginx_version >= 1011011 + ngx_pool_cleanup_t *cln; + #endif + +@@ -716,6 +717,16 @@ ngx_http_lua_init(ngx_conf_t *cf) + cln->handler = ngx_http_lua_sema_mm_cleanup; + #endif + ++#if nginx_version >= 1011011 ++ cln = ngx_pool_cleanup_add(cf->pool, 0); ++ if (cln == NULL) { ++ return NGX_ERROR; ++ } ++ ++ cln->data = lmcf; ++ cln->handler = ngx_http_lua_ngx_raw_header_cleanup; ++#endif ++ + if (lmcf->lua == NULL) { + dd("initializing lua vm"); + -- cgit v1.2.3