passenger 4.0.59 → 4.0.60
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of passenger might be problematic. Click here for more details.
- checksums.yaml +8 -8
- checksums.yaml.gz.asc +7 -7
- data.tar.gz.asc +7 -7
- data/CHANGELOG +15 -0
- data/bin/passenger-install-apache2-module +2 -1
- data/bin/passenger-install-nginx-module +8 -2
- data/ext/apache2/Hooks.cpp +21 -2
- data/ext/apache2/MergeDirConfig.cpp +40 -40
- data/ext/common/ApplicationPool2/Group.h +14 -10
- data/ext/common/ApplicationPool2/Implementation.cpp +13 -7
- data/ext/common/ApplicationPool2/SmartSpawner.h +4 -1
- data/ext/common/Constants.h +1 -1
- data/ext/nginx/ContentHandler.c +17 -1
- data/lib/phusion_passenger.rb +4 -5
- data/lib/phusion_passenger/platform_info/depcheck_specs/libs.rb +4 -3
- data/lib/phusion_passenger/platform_info/openssl.rb +61 -0
- data/lib/phusion_passenger/standalone/runtime_installer.rb +27 -22
- data/packaging/debian/LICENSE.md +19 -0
- data/packaging/debian/README.md +320 -0
- data/packaging/debian/Vagrantfile +25 -0
- data/packaging/debian/build +210 -0
- data/packaging/debian/debian_specs/nginx/changelog +1989 -0
- data/packaging/debian/debian_specs/nginx/compat.erb +5 -0
- data/packaging/debian/debian_specs/nginx/conf/fastcgi.conf +25 -0
- data/packaging/debian/debian_specs/nginx/conf/fastcgi_params +24 -0
- data/packaging/debian/debian_specs/nginx/conf/koi-utf +109 -0
- data/packaging/debian/debian_specs/nginx/conf/koi-win +103 -0
- data/packaging/debian/debian_specs/nginx/conf/mime.types +89 -0
- data/packaging/debian/debian_specs/nginx/conf/nginx.conf.erb +97 -0
- data/packaging/debian/debian_specs/nginx/conf/proxy_params +4 -0
- data/packaging/debian/debian_specs/nginx/conf/scgi_params +16 -0
- data/packaging/debian/debian_specs/nginx/conf/sites-available/default.erb +93 -0
- data/packaging/debian/debian_specs/nginx/conf/snippets/fastcgi-php.conf +13 -0
- data/packaging/debian/debian_specs/nginx/conf/snippets/snakeoil.conf +5 -0
- data/packaging/debian/debian_specs/nginx/conf/uwsgi_params +16 -0
- data/packaging/debian/debian_specs/nginx/conf/win-utf +125 -0
- data/packaging/debian/debian_specs/nginx/control.erb +226 -0
- data/packaging/debian/debian_specs/nginx/copyright +196 -0
- data/packaging/debian/debian_specs/nginx/debian-full.lintian-overrides +1 -0
- data/packaging/debian/debian_specs/nginx/gbp.conf +2 -0
- data/packaging/debian/debian_specs/nginx/help/docs/fcgiwrap +14 -0
- data/packaging/debian/debian_specs/nginx/help/docs/php +119 -0
- data/packaging/debian/debian_specs/nginx/help/docs/support-irc +28 -0
- data/packaging/debian/debian_specs/nginx/help/docs/upstream +51 -0
- data/packaging/debian/debian_specs/nginx/help/examples/drupal +114 -0
- data/packaging/debian/debian_specs/nginx/help/examples/http +59 -0
- data/packaging/debian/debian_specs/nginx/help/examples/mail +30 -0
- data/packaging/debian/debian_specs/nginx/help/examples/mailman +59 -0
- data/packaging/debian/debian_specs/nginx/help/examples/nginx.conf +34 -0
- data/packaging/debian/debian_specs/nginx/help/examples/nginx_modsite +162 -0
- data/packaging/debian/debian_specs/nginx/help/examples/virtual_hosts +155 -0
- data/packaging/debian/debian_specs/nginx/help/examples/wordpress +74 -0
- data/packaging/debian/debian_specs/nginx/helpers.rb +41 -0
- data/packaging/debian/debian_specs/nginx/index-debian.html.in +32 -0
- data/packaging/debian/debian_specs/nginx/index-ubuntu.html.in +32 -0
- data/packaging/debian/debian_specs/nginx/index.html.erb +10 -0
- data/packaging/debian/debian_specs/nginx/modules/README.Modules-versions +65 -0
- data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/README.markdown +510 -0
- data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/config +5 -0
- data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/doc/HttpHeadersMoreModule.wiki +395 -0
- data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ddebug.h +119 -0
- data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_filter_module.c +348 -0
- data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_filter_module.h +80 -0
- data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_headers_in.c +826 -0
- data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_headers_in.h +26 -0
- data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_headers_out.c +716 -0
- data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_headers_out.h +26 -0
- data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_util.c +380 -0
- data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_util.h +52 -0
- data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/util/build.sh +32 -0
- data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/valgrind.suppress +215 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-auth-pam/ChangeLog +35 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-auth-pam/LICENSE +25 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-auth-pam/README.md +93 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-auth-pam/config +4 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-auth-pam/ngx_http_auth_pam_module.c +462 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-cache-purge/CHANGES +66 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-cache-purge/LICENSE +26 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-cache-purge/README.md +171 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-cache-purge/TODO.md +7 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-cache-purge/config +21 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-cache-purge/ngx_cache_purge_module.c +1803 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-dav-ext-module/README +29 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-dav-ext-module/config +9 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-dav-ext-module/ngx_http_dav_ext_module.c +824 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/README +139 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/README_AUTO_LIB +395 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/TODO +1 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/actions/array +10 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/actions/palloc +8 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/build +597 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/action_replacements +5 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/action_types +12 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/conf_args +22 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/conf_locs +25 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/conf_macros +35 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/contexts +22 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/header_files +3 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/headers +4 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/module_dependencies +5 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/modules_optional +15 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/prefixes +2 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/src/array.h +7 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/src/conf_cmd_basic.h +43 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/src/conf_merge.h +78 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/src/palloc.h +6 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/text/autogen +12 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/config +49 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/docs/core/action_macros +63 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/docs/core/conf_cmds +62 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/docs/modules/set_var +124 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/docs/patches/more_logging_info +48 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/docs/upstream/list +45 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/examples/README +12 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/examples/http/set_var/config +4 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/examples/http/set_var/ngx_http_set_var_examples_module.c +136 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/ngx_auto_lib_core +797 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/notes/CHANGES +17 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/notes/LICENSE +24 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_array.h +113 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_conf_cmd_basic.h +2203 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_conf_cmd_extra.h +5423 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_conf_merge.h +227 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_config.c +72 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_config.h +98 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_includes.h +66 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_palloc.h +112 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/patches/auto_config +16 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/patches/expose_rewrite_functions +291 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/patches/rewrite_phase_handler +19 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/hash/md5.h +117 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/hash/murmurhash2.c +77 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/hash/sha.h +200 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk.c +155 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk.h +58 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_buf.c +43 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_buf.h +5 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_complex_path.c +129 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_complex_path.h +30 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_complex_value.c +192 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_complex_value.h +21 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_conf_file.c +396 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_conf_file.h +44 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_debug.c +72 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_debug.h +171 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_encoding.c +57 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_encoding.h +12 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_hash.c +82 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_hash.h +45 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_http.c +138 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_http.h +3 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_http_headers.h +35 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_log.c +3 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_log.h +165 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_parse.h +67 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_path.c +583 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_path.h +22 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_process.c +20 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_process.h +12 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_regex.c +215 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_regex.h +7 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_rewrite.c +103 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_rewrite.h +26 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_set_var.c +602 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_set_var.h +44 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_string.c +434 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_string.h +37 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_string_util.h +14 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_upstream_list.c +205 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_upstream_list.h +27 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_uri.c +45 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_uri.h +6 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/LICENSE +25 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/README.markdown +1850 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/config +5 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/doc/HttpEchoModule.wiki +1558 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ddebug.h +109 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_echo.c +344 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_echo.h +25 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_filter.c +282 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_filter.h +15 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_foreach.c +183 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_foreach.h +16 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_handler.c +429 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_handler.h +18 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_location.c +178 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_location.h +13 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_module.c +667 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_module.h +137 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_request_info.c +452 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_request_info.h +31 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_sleep.c +208 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_sleep.h +16 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_subrequest.c +788 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_subrequest.h +19 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_timer.c +96 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_timer.h +13 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_util.c +298 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_util.h +58 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_var.c +110 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_var.h +9 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/util/build.sh +45 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/util/releng +8 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/util/wiki2pod.pl +131 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/valgrind.suppress +38 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/LICENCE +24 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/README +206 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/changelog.txt +54 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/config +26 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/protocol.txt +191 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/ngx_http_push_defs.c +59 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/ngx_http_push_defs.h +73 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/ngx_http_push_module.c +783 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/ngx_http_push_module.h +31 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/ngx_http_push_module_setup.c +361 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/ngx_http_push_types.h +120 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/memory/store.c +1180 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/memory/store.h +1 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/ngx_http_push_module_ipc.c +146 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/ngx_http_push_module_ipc.h +5 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/ngx_http_push_store.h +51 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/ngx_rwlock.c +178 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/ngx_rwlock.h +5 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/rbtree_util.c +246 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/rbtree_util.h +9 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/Changes +51 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/README.markdown +6954 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/config +363 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/doc/HttpLuaModule.wiki +5898 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/dtrace/ngx_lua_provider.d +61 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/misc/recv-until-pm/Makefile +3 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/misc/recv-until-pm/lib/RecvUntil.pm +138 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/misc/recv-until-pm/t/sanity.t +140 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/api/ngx_http_lua_api.h +52 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ddebug.h +82 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_accessby.c +377 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_accessby.h +22 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_api.c +77 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_args.c +537 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_args.h +20 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_bodyfilterby.c +632 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_bodyfilterby.h +31 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_cache.c +296 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_cache.h +24 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_capturefilter.c +175 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_capturefilter.h +20 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_clfactory.c +887 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_clfactory.h +22 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_common.h +478 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_config.c +67 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_config.h +19 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_consts.c +148 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_consts.h +20 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_contentby.c +369 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_contentby.h +26 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_control.c +483 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_control.h +20 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_coroutine.c +379 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_coroutine.h +23 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_ctx.c +216 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_ctx.h +23 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_directive.c +1081 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_directive.h +56 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_exception.c +58 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_exception.h +33 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headerfilterby.c +302 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headerfilterby.h +29 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headers.c +1370 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headers.h +22 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headers_in.c +782 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headers_in.h +22 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headers_out.c +625 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headers_out.h +23 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_initby.c +42 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_initby.h +23 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_initworkerby.c +320 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_initworkerby.h +25 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_log.c +300 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_log.h +20 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_logby.c +227 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_logby.h +22 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_misc.c +252 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_misc.h +20 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_module.c +924 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_ndk.c +184 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_ndk.h +21 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_output.c +794 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_output.h +28 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_pcrefix.c +106 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_pcrefix.h +23 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_phase.c +94 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_phase.h +13 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_probe.h +85 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_regex.c +2468 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_regex.h +22 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_req_body.c +1169 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_req_body.h +20 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_req_method.c +252 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_req_method.h +19 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_rewriteby.c +351 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_rewriteby.h +22 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_script.c +538 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_script.h +86 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_setby.c +216 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_setby.h +15 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_shdict.c +1844 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_shdict.h +52 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_sleep.c +191 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_sleep.h +20 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_socket_tcp.c +5314 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_socket_tcp.h +156 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_socket_udp.c +1624 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_socket_udp.h +56 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_string.c +704 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_string.h +20 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_subrequest.c +1741 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_subrequest.h +46 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_time.c +278 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_time.h +21 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_timer.c +661 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_timer.h +20 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_uri.c +110 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_uri.h +20 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_uthread.c +283 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_uthread.h +36 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_util.c +3972 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_util.h +423 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_variable.c +499 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_variable.h +20 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_worker.c +64 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_worker.h +17 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/tapset/ngx_lua.stp +5 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/build.sh +39 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/build2.sh +55 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/fix-comments +27 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/gdbinit +415 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/ngx-links +62 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/reindex +64 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/releng +8 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/retab +8 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/revim +102 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/run_test.sh +10 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/update-readme.sh +4 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/valgrind.suppress +144 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-upload-progress/CHANGES +107 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-upload-progress/LICENSE +25 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-upload-progress/Makefile +8 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-upload-progress/README +329 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-upload-progress/config +3 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-upload-progress/ngx_http_uploadprogress_module.c +1774 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-upstream-fair/README +53 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-upstream-fair/config +3 -0
- data/packaging/debian/debian_specs/nginx/modules/nginx-upstream-fair/ngx_http_upstream_fair_module.c +1356 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/CHANGELOG.md +37 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/HACKING.md +24 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/LICENSE +20 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/README.rst +182 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/config +8 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/nginx-0.6-support.patch +23 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/ngx_http_fancyindex_module.c +1305 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/template.awk +52 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/template.h +103 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/template.html +102 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/CHANGES +37 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/README +141 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/config +3 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/doc/README.google_code_home_page.wiki +120 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/doc/README.html +199 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/doc/README.wiki +123 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/ngx_http_subs_filter_module.c +1298 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/README +275 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/AutoInstall.pm +820 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install.pm +470 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/AutoInstall.pm +82 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/Base.pm +83 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/Can.pm +81 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/Fetch.pm +93 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/Include.pm +34 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/Makefile.pm +415 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/Metadata.pm +716 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/TestBase.pm +29 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/Win32.pm +64 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/WriteAll.pm +63 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Spiffy.pm +539 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Test/Base.pm +682 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Test/Base/Filter.pm +341 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Test/Builder.pm +1413 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Test/Builder/Module.pm +81 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Test/More.pm +735 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/lib/Test/Nginx.pm +315 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/lib/Test/Nginx/LWP.pm +524 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/lib/Test/Nginx/Socket.pm +1749 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/lib/Test/Nginx/Util.pm +874 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/t/subs.t +136 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/t/subs_capture.t +32 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/t/subs_fix_string.t +32 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/t/subs_regex.t +108 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/t/subs_types.t +59 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/test.sh +5 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/util/update-readme.sh +7 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/util/wiki2google_code_homepage.pl +29 -0
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/util/wiki2pod.pl +129 -0
- data/packaging/debian/debian_specs/nginx/nginx-common.NEWS +135 -0
- data/packaging/debian/debian_specs/nginx/nginx-common.README.Debian +45 -0
- data/packaging/debian/debian_specs/nginx/nginx-common.dirs.erb +32 -0
- data/packaging/debian/debian_specs/nginx/nginx-common.install +3 -0
- data/packaging/debian/debian_specs/nginx/nginx-common.lintian-overrides +2 -0
- data/packaging/debian/debian_specs/nginx/nginx-common.manpages +1 -0
- data/packaging/debian/debian_specs/nginx/nginx-common.nginx.default +10 -0
- data/packaging/debian/debian_specs/nginx/nginx-common.nginx.init.erb +214 -0
- data/packaging/debian/debian_specs/nginx/nginx-common.nginx.logrotate +18 -0
- data/packaging/debian/debian_specs/nginx/nginx-common.nginx.service.erb +37 -0
- data/packaging/debian/debian_specs/nginx/nginx-common.postinst.erb +66 -0
- data/packaging/debian/debian_specs/nginx/nginx-common.postrm.erb +46 -0
- data/packaging/debian/debian_specs/nginx/nginx-common.preinst +47 -0
- data/packaging/debian/debian_specs/nginx/nginx-common.prerm.erb +28 -0
- data/packaging/debian/debian_specs/nginx/nginx-doc.docs +2 -0
- data/packaging/debian/debian_specs/nginx/nginx-doc.examples +1 -0
- data/packaging/debian/debian_specs/nginx/nginx-extras.install.erb +17 -0
- data/packaging/debian/debian_specs/nginx/nginx-extras.lintian-overrides +1 -0
- data/packaging/debian/debian_specs/nginx/nginx-extras.postinst.erb +44 -0
- data/packaging/debian/debian_specs/nginx/nginx-extras.prerm +22 -0
- data/packaging/debian/debian_specs/nginx/nginx.1 +47 -0
- data/packaging/debian/debian_specs/nginx/patches/perl-use-dpkg-buildflags.patch +23 -0
- data/packaging/debian/debian_specs/nginx/patches/series +1 -0
- data/packaging/debian/debian_specs/nginx/rules.erb +185 -0
- data/packaging/debian/debian_specs/nginx/source/format +1 -0
- data/packaging/debian/debian_specs/nginx/tests/control +4 -0
- data/packaging/debian/debian_specs/nginx/ufw/nginx +14 -0
- data/packaging/debian/debian_specs/nginx/upstream/signing-key.asc +34 -0
- data/packaging/debian/debian_specs/nginx/watch +3 -0
- data/packaging/debian/debian_specs/passenger/README.Debian +12 -0
- data/packaging/debian/debian_specs/passenger/changelog +316 -0
- data/packaging/debian/debian_specs/passenger/compat +1 -0
- data/packaging/debian/debian_specs/passenger/control.erb +123 -0
- data/packaging/debian/debian_specs/passenger/copyright +385 -0
- data/packaging/debian/debian_specs/passenger/helpers.rb +24 -0
- data/packaging/debian/debian_specs/passenger/libapache2-mod-passenger.install +3 -0
- data/packaging/debian/debian_specs/passenger/libapache2-mod-passenger.postinst +36 -0
- data/packaging/debian/debian_specs/passenger/libapache2-mod-passenger.prerm +15 -0
- data/packaging/debian/debian_specs/passenger/locations.ini.erb +14 -0
- data/packaging/debian/debian_specs/passenger/passenger-dev.install.erb +3 -0
- data/packaging/debian/debian_specs/passenger/passenger-doc.install.erb +2 -0
- data/packaging/debian/debian_specs/passenger/passenger.conf +6 -0
- data/packaging/debian/debian_specs/passenger/passenger.docs +4 -0
- data/packaging/debian/debian_specs/passenger/passenger.install.erb +16 -0
- data/packaging/debian/debian_specs/passenger/passenger.load +3 -0
- data/packaging/debian/debian_specs/passenger/passenger.manpages +3 -0
- data/packaging/debian/debian_specs/passenger/passenger_free_ruby.c +29 -0
- data/packaging/debian/debian_specs/passenger/passenger_ruby_utils.c +54 -0
- data/packaging/debian/debian_specs/passenger/passenger_system_ruby.c.erb +37 -0
- data/packaging/debian/debian_specs/passenger/patches/series +0 -0
- data/packaging/debian/debian_specs/passenger/rules.erb +84 -0
- data/packaging/debian/debian_specs/passenger/source/format +1 -0
- data/packaging/debian/debian_specs/passenger_enterprise/README.Debian +12 -0
- data/packaging/debian/debian_specs/passenger_enterprise/changelog +316 -0
- data/packaging/debian/debian_specs/passenger_enterprise/compat +1 -0
- data/packaging/debian/debian_specs/passenger_enterprise/control.erb +123 -0
- data/packaging/debian/debian_specs/passenger_enterprise/copyright +385 -0
- data/packaging/debian/debian_specs/passenger_enterprise/helpers.rb +2 -0
- data/packaging/debian/debian_specs/passenger_enterprise/libapache2-mod-passenger-enterprise.install +3 -0
- data/packaging/debian/debian_specs/passenger_enterprise/libapache2-mod-passenger-enterprise.postinst +36 -0
- data/packaging/debian/debian_specs/passenger_enterprise/libapache2-mod-passenger-enterprise.prerm +15 -0
- data/packaging/debian/debian_specs/passenger_enterprise/locations.ini.erb +14 -0
- data/packaging/debian/debian_specs/passenger_enterprise/passenger-enterprise-dev.install.erb +3 -0
- data/packaging/debian/debian_specs/passenger_enterprise/passenger-enterprise-doc.install.erb +2 -0
- data/packaging/debian/debian_specs/passenger_enterprise/passenger-enterprise.docs +4 -0
- data/packaging/debian/debian_specs/passenger_enterprise/passenger-enterprise.install.erb +14 -0
- data/packaging/debian/debian_specs/passenger_enterprise/passenger-enterprise.manpages +3 -0
- data/packaging/debian/debian_specs/passenger_enterprise/passenger.conf +6 -0
- data/packaging/debian/debian_specs/passenger_enterprise/passenger.load +3 -0
- data/packaging/debian/debian_specs/passenger_enterprise/passenger_free_ruby.c.erb +1 -0
- data/packaging/debian/debian_specs/passenger_enterprise/passenger_ruby_utils.c.erb +1 -0
- data/packaging/debian/debian_specs/passenger_enterprise/passenger_system_ruby.c.erb +1 -0
- data/packaging/debian/debian_specs/passenger_enterprise/patches/series +0 -0
- data/packaging/debian/debian_specs/passenger_enterprise/rules.erb +84 -0
- data/packaging/debian/debian_specs/passenger_enterprise/source/format +1 -0
- data/packaging/debian/docker_images/Makefile +38 -0
- data/packaging/debian/docker_images/buildbox/CONTAINER_VERSION.txt +0 -0
- data/packaging/debian/docker_images/buildbox/Dockerfile +3 -0
- data/packaging/debian/docker_images/buildbox/Gemfile +9 -0
- data/packaging/debian/docker_images/buildbox/Gemfile.lock +42 -0
- data/packaging/debian/docker_images/buildbox/install.sh +85 -0
- data/packaging/debian/docker_images/buildbox/pbuilderrc +4 -0
- data/packaging/debian/docker_images/buildbox/sudoers.conf +6 -0
- data/packaging/debian/docker_images/setup-buildbox-docker-image +7 -0
- data/packaging/debian/docker_images/setup-testbox-docker-image-debian-6 +7 -0
- data/packaging/debian/docker_images/setup-testbox-docker-image-debian-7 +7 -0
- data/packaging/debian/docker_images/setup-testbox-docker-image-debian-8 +7 -0
- data/packaging/debian/docker_images/setup-testbox-docker-image-ubuntu-12.04 +7 -0
- data/packaging/debian/docker_images/setup-testbox-docker-image-ubuntu-14.04 +7 -0
- data/packaging/debian/docker_images/setup-testbox-docker-image-ubuntu-15.04 +7 -0
- data/packaging/debian/docker_images/setup-testbox-docker-image-ubuntu-15.10 +7 -0
- data/packaging/debian/docker_images/testbox-debian-6/Dockerfile +3 -0
- data/packaging/debian/docker_images/testbox-debian-6/Gemfile +2 -0
- data/packaging/debian/docker_images/testbox-debian-6/Gemfile.lock +23 -0
- data/packaging/debian/docker_images/testbox-debian-6/argparse.py +2374 -0
- data/packaging/debian/docker_images/testbox-debian-6/install.sh +78 -0
- data/packaging/debian/docker_images/testbox-debian-7/Dockerfile +3 -0
- data/packaging/debian/docker_images/testbox-debian-7/Gemfile +2 -0
- data/packaging/debian/docker_images/testbox-debian-7/Gemfile.lock +23 -0
- data/packaging/debian/docker_images/testbox-debian-7/install.sh +71 -0
- data/packaging/debian/docker_images/testbox-debian-8/Dockerfile +3 -0
- data/packaging/debian/docker_images/testbox-debian-8/Gemfile +2 -0
- data/packaging/debian/docker_images/testbox-debian-8/Gemfile.lock +23 -0
- data/packaging/debian/docker_images/testbox-debian-8/install.sh +70 -0
- data/packaging/debian/docker_images/testbox-ubuntu-12.04/Dockerfile +3 -0
- data/packaging/debian/docker_images/testbox-ubuntu-12.04/Gemfile +2 -0
- data/packaging/debian/docker_images/testbox-ubuntu-12.04/Gemfile.lock +23 -0
- data/packaging/debian/docker_images/testbox-ubuntu-12.04/install.sh +69 -0
- data/packaging/debian/docker_images/testbox-ubuntu-14.04/Dockerfile +3 -0
- data/packaging/debian/docker_images/testbox-ubuntu-14.04/Gemfile +2 -0
- data/packaging/debian/docker_images/testbox-ubuntu-14.04/Gemfile.lock +23 -0
- data/packaging/debian/docker_images/testbox-ubuntu-14.04/install.sh +69 -0
- data/packaging/debian/docker_images/testbox-ubuntu-15.04/Dockerfile +3 -0
- data/packaging/debian/docker_images/testbox-ubuntu-15.04/Gemfile +2 -0
- data/packaging/debian/docker_images/testbox-ubuntu-15.04/Gemfile.lock +23 -0
- data/packaging/debian/docker_images/testbox-ubuntu-15.04/install.sh +69 -0
- data/packaging/debian/docker_images/testbox-ubuntu-15.10/Dockerfile +3 -0
- data/packaging/debian/docker_images/testbox-ubuntu-15.10/Gemfile +2 -0
- data/packaging/debian/docker_images/testbox-ubuntu-15.10/Gemfile.lock +23 -0
- data/packaging/debian/docker_images/testbox-ubuntu-15.10/install.sh +69 -0
- data/packaging/debian/internal/build/Rakefile +235 -0
- data/packaging/debian/internal/build/build-passenger-orig-tarball.sh +76 -0
- data/packaging/debian/internal/build/build-source-package.rb +121 -0
- data/packaging/debian/internal/build/download-nginx-orig-tarball.sh +17 -0
- data/packaging/debian/internal/build/rakefile_support.rb +96 -0
- data/packaging/debian/internal/build/setup-environment-essentials.sh +15 -0
- data/packaging/debian/internal/build/setup-environment.sh +29 -0
- data/packaging/debian/internal/lib/distro_info.rb +82 -0
- data/packaging/debian/internal/lib/distro_info.sh +303 -0
- data/packaging/debian/internal/lib/distro_info.sh.erb +65 -0
- data/packaging/debian/internal/lib/library.sh +83 -0
- data/packaging/debian/internal/lib/preprocessor.rb +173 -0
- data/packaging/debian/internal/lib/tracking.rb +95 -0
- data/packaging/debian/internal/lib/tracking_category.rb +45 -0
- data/packaging/debian/internal/lib/tracking_database.rb +132 -0
- data/packaging/debian/internal/lib/tracking_task.rb +148 -0
- data/packaging/debian/internal/lib/utils.rb +78 -0
- data/packaging/debian/internal/publish/Rakefile +97 -0
- data/packaging/debian/internal/publish/oss-binaries.phusionpassenger.com-fingerprint.txt +1 -0
- data/packaging/debian/internal/publish/packagecloud_fingerprint.txt +1 -0
- data/packaging/debian/internal/publish/passenger_website_fingerprint.txt +1 -0
- data/packaging/debian/internal/publish/preinit.sh +7 -0
- data/packaging/debian/internal/publish/rakefile_support.rb +183 -0
- data/packaging/debian/internal/scripts/gpg_noninteractive/gpg +11 -0
- data/packaging/debian/internal/scripts/initccache.sh +35 -0
- data/packaging/debian/internal/scripts/inituidgid.sh +19 -0
- data/packaging/debian/internal/scripts/my_init +340 -0
- data/packaging/debian/internal/scripts/pin_certificates +34 -0
- data/packaging/debian/internal/scripts/regen_distro_info_script.sh +3 -0
- data/packaging/debian/internal/scripts/setup-vagrant.sh +12 -0
- data/packaging/debian/internal/scripts/setuser +31 -0
- data/packaging/debian/internal/shell/initpbuilder.sh +3 -0
- data/packaging/debian/internal/shell/preinit.sh +28 -0
- data/packaging/debian/internal/shell/sudoers.conf +1 -0
- data/packaging/debian/internal/test/apache/apache-24.conf +5 -0
- data/packaging/debian/internal/test/apache/apache-pre-24.conf +4 -0
- data/packaging/debian/internal/test/apache/vhost.conf +17 -0
- data/packaging/debian/internal/test/misc/config.json +15 -0
- data/packaging/debian/internal/test/misc/hosts.conf +4 -0
- data/packaging/debian/internal/test/misc/init.sh +25 -0
- data/packaging/debian/internal/test/misc/nodejs_test_app.js +6 -0
- data/packaging/debian/internal/test/misc/python_test_app.py +3 -0
- data/packaging/debian/internal/test/misc/ruby_test_app.rb +5 -0
- data/packaging/debian/internal/test/misc/test_support.rb +61 -0
- data/packaging/debian/internal/test/nginx/vhost.conf +23 -0
- data/packaging/debian/internal/test/system_web_server_test.rb +126 -0
- data/packaging/debian/internal/test/test.sh +141 -0
- data/packaging/debian/jenkins/publish/clear_caches.rb +48 -0
- data/packaging/debian/jenkins/publish/publish.sh +69 -0
- data/packaging/debian/jenkins/test/test.sh +63 -0
- data/packaging/debian/passenger_apt_automation.sublime-project +14 -0
- data/packaging/debian/publish +172 -0
- data/packaging/debian/shell +116 -0
- data/packaging/debian/test +142 -0
- metadata +563 -3
- metadata.gz.asc +7 -7
- data/resources/oss-binaries.phusionpassenger.com.crt +0 -208
@@ -0,0 +1,1180 @@
|
|
1
|
+
#include <ngx_http_push_module.h>
|
2
|
+
|
3
|
+
#include "store.h"
|
4
|
+
#include <store/rbtree_util.h>
|
5
|
+
#include <store/ngx_rwlock.h>
|
6
|
+
#include <store/ngx_http_push_module_ipc.h>
|
7
|
+
|
8
|
+
#define NGX_HTTP_PUSH_BROADCAST_CHECK(val, fail, r, errormessage) \
|
9
|
+
if (val == fail) { \
|
10
|
+
ngx_log_error(NGX_LOG_ERR, (r)->connection->log, 0, errormessage); \
|
11
|
+
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); \
|
12
|
+
return NULL; \
|
13
|
+
}
|
14
|
+
|
15
|
+
#define NGX_HTTP_PUSH_BROADCAST_CHECK_LOCKED(val, fail, r, errormessage, shpool) \
|
16
|
+
if (val == fail) { \
|
17
|
+
ngx_shmtx_unlock(&(shpool)->mutex); \
|
18
|
+
ngx_log_error(NGX_LOG_ERR, (r)->connection->log, 0, errormessage); \
|
19
|
+
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); \
|
20
|
+
return NULL; \
|
21
|
+
}
|
22
|
+
|
23
|
+
#define NGX_HTTP_BUF_ALLOC_SIZE(buf) \
|
24
|
+
(sizeof(*buf) + \
|
25
|
+
(((buf)->temporary || (buf)->memory) ? ngx_buf_size(buf) : 0) + \
|
26
|
+
(((buf)->file!=NULL) ? (sizeof(*(buf)->file) + (buf)->file->name.len + 1) : 0))
|
27
|
+
|
28
|
+
#define ENQUEUED_DBG "msg %p enqueued. ref:%i, p:%p n:%p"
|
29
|
+
#define CREATED_DBG "msg %p created ref:%i, p:%p n:%p"
|
30
|
+
#define FREED_DBG "msg %p freed. ref:%i, p:%p n:%p"
|
31
|
+
#define RESERVED_DBG "msg %p reserved. ref:%i, p:%p n:%p"
|
32
|
+
#define RELEASED_DBG "msg %p released. ref:%i, p:%p n:%p"
|
33
|
+
|
34
|
+
//#define DEBUG_SHM_ALLOC 1
|
35
|
+
|
36
|
+
static ngx_http_push_channel_queue_t channel_gc_sentinel;
|
37
|
+
static ngx_slab_pool_t *ngx_http_push_shpool = NULL;
|
38
|
+
static ngx_shm_zone_t *ngx_http_push_shm_zone = NULL;
|
39
|
+
|
40
|
+
static ngx_int_t ngx_http_push_store_send_worker_message(ngx_http_push_channel_t *channel, ngx_http_push_subscriber_t *subscriber_sentinel, ngx_pid_t pid, ngx_int_t worker_slot, ngx_http_push_msg_t *msg, ngx_int_t status_code);
|
41
|
+
|
42
|
+
static ngx_int_t ngx_http_push_channel_collector(ngx_http_push_channel_t * channel) {
|
43
|
+
if((ngx_http_push_clean_channel_locked(channel))!=NULL) { //we're up for deletion
|
44
|
+
ngx_http_push_channel_queue_t *trashy;
|
45
|
+
if((trashy = ngx_alloc(sizeof(*trashy), ngx_cycle->log))!=NULL) {
|
46
|
+
//yeah, i'm allocating memory during garbage collection. sue me.
|
47
|
+
trashy->channel=channel;
|
48
|
+
ngx_queue_insert_tail(&channel_gc_sentinel.queue, &trashy->queue);
|
49
|
+
return NGX_OK;
|
50
|
+
}
|
51
|
+
return NGX_ERROR;
|
52
|
+
}
|
53
|
+
return NGX_OK;
|
54
|
+
}
|
55
|
+
|
56
|
+
static void ngx_http_push_store_lock_shmem(void){
|
57
|
+
ngx_shmtx_lock(&ngx_http_push_shpool->mutex);
|
58
|
+
}
|
59
|
+
static void ngx_http_push_store_unlock_shmem(void){
|
60
|
+
ngx_shmtx_unlock(&ngx_http_push_shpool->mutex);
|
61
|
+
}
|
62
|
+
|
63
|
+
//garbage-collecting slab allocator
|
64
|
+
static void * ngx_http_push_slab_alloc_locked(size_t size, char *label) {
|
65
|
+
void *p;
|
66
|
+
if((p = ngx_slab_alloc_locked(ngx_http_push_shpool, size))==NULL) {
|
67
|
+
ngx_http_push_channel_queue_t *ccur, *cnext;
|
68
|
+
ngx_uint_t collected = 0;
|
69
|
+
//failed. emergency garbage sweep, then.
|
70
|
+
|
71
|
+
//collect channels
|
72
|
+
ngx_queue_init(&channel_gc_sentinel.queue);
|
73
|
+
ngx_http_push_walk_rbtree(ngx_http_push_channel_collector, ngx_http_push_shm_zone);
|
74
|
+
for(ccur=(ngx_http_push_channel_queue_t *)ngx_queue_next(&channel_gc_sentinel.queue); ccur != &channel_gc_sentinel; ccur=cnext) {
|
75
|
+
cnext = (ngx_http_push_channel_queue_t *)ngx_queue_next(&ccur->queue);
|
76
|
+
ngx_http_push_delete_channel_locked(ccur->channel, ngx_http_push_shm_zone);
|
77
|
+
ngx_free(ccur);
|
78
|
+
collected++;
|
79
|
+
}
|
80
|
+
|
81
|
+
//todo: collect worker messages maybe
|
82
|
+
|
83
|
+
ngx_log_error(NGX_LOG_WARN, ngx_cycle->log, 0, "push module: out of shared memory. emergency garbage collection deleted %ui unused channels.", collected);
|
84
|
+
|
85
|
+
p = ngx_slab_alloc_locked(ngx_http_push_shpool, size);
|
86
|
+
}
|
87
|
+
#if (DEBUG_SHM_ALLOC == 1)
|
88
|
+
if (p != NULL) {
|
89
|
+
if(label==NULL)
|
90
|
+
label="none";
|
91
|
+
ngx_log_error(NGX_LOG_WARN, ngx_cycle->log, 0, "shpool alloc addr %p size %ui label %s", p, size, label);
|
92
|
+
}
|
93
|
+
#endif
|
94
|
+
return p;
|
95
|
+
}
|
96
|
+
|
97
|
+
static void * ngx_http_push_slab_alloc(size_t size, char *label) {
|
98
|
+
void * p;
|
99
|
+
ngx_http_push_store_lock_shmem();
|
100
|
+
p= ngx_http_push_slab_alloc_locked(size, label);
|
101
|
+
ngx_http_push_store_unlock_shmem();
|
102
|
+
return p;
|
103
|
+
}
|
104
|
+
|
105
|
+
static void ngx_http_push_slab_free_locked(void *ptr) {
|
106
|
+
ngx_slab_free_locked(ngx_http_push_shpool, ptr);
|
107
|
+
#if (DEBUG_SHM_ALLOC == 1)
|
108
|
+
ngx_log_error(NGX_LOG_WARN, ngx_cycle->log, 0, "shpool free addr %p", ptr);
|
109
|
+
#endif
|
110
|
+
}
|
111
|
+
/*
|
112
|
+
static void ngx_http_push_slab_free(void *ptr) {
|
113
|
+
ngx_http_push_store_lock_shmem();
|
114
|
+
ngx_http_push_slab_free_locked(ptr);
|
115
|
+
ngx_http_push_store_unlock_shmem();
|
116
|
+
}*/
|
117
|
+
|
118
|
+
//shpool is assumed to be locked.
|
119
|
+
static ngx_http_push_msg_t *ngx_http_push_get_latest_message_locked(ngx_http_push_channel_t * channel) {
|
120
|
+
ngx_queue_t *sentinel = &channel->message_queue->queue;
|
121
|
+
if(ngx_queue_empty(sentinel)) {
|
122
|
+
return NULL;
|
123
|
+
}
|
124
|
+
ngx_queue_t *qmsg = ngx_queue_last(sentinel);
|
125
|
+
return ngx_queue_data(qmsg, ngx_http_push_msg_t, queue);
|
126
|
+
}
|
127
|
+
|
128
|
+
//shpool must be locked. No memory is freed. O(1)
|
129
|
+
static ngx_http_push_msg_t *ngx_http_push_get_oldest_message_locked(ngx_http_push_channel_t * channel) {
|
130
|
+
ngx_queue_t *sentinel = &channel->message_queue->queue;
|
131
|
+
if(ngx_queue_empty(sentinel)) {
|
132
|
+
return NULL;
|
133
|
+
}
|
134
|
+
ngx_queue_t *qmsg = ngx_queue_head(sentinel);
|
135
|
+
return ngx_queue_data(qmsg, ngx_http_push_msg_t, queue);
|
136
|
+
}
|
137
|
+
|
138
|
+
static void ngx_http_push_store_reserve_message_locked(ngx_http_push_channel_t *channel, ngx_http_push_msg_t *msg) {
|
139
|
+
if(msg == NULL) {
|
140
|
+
return;
|
141
|
+
}
|
142
|
+
msg->refcount++;
|
143
|
+
//ngx_log_error(NGX_LOG_WARN, ngx_cycle->log, 0, RESERVED_DBG, msg, msg->refcount, msg->queue.prev, msg->queue.next);
|
144
|
+
//we need a refcount because channel messages MAY be dequed before they are used up. It thus falls on the IPC stuff to free it.
|
145
|
+
}
|
146
|
+
|
147
|
+
static void ngx_http_push_store_reserve_message_num_locked(ngx_http_push_channel_t *channel, ngx_http_push_msg_t *msg, ngx_int_t reservations) {
|
148
|
+
if(msg == NULL) {
|
149
|
+
return;
|
150
|
+
}
|
151
|
+
msg->refcount+=reservations;
|
152
|
+
//ngx_log_error(NGX_LOG_WARN, ngx_cycle->log, 0, RESERVED_DBG, msg, msg->refcount, msg->queue.prev, msg->queue.next);
|
153
|
+
//we need a refcount because channel messages MAY be dequed before they are used up. It thus falls on the IPC stuff to free it.
|
154
|
+
}
|
155
|
+
|
156
|
+
static void ngx_http_push_store_reserve_message(ngx_http_push_channel_t *channel, ngx_http_push_msg_t *msg) {
|
157
|
+
ngx_shmtx_lock(&ngx_http_push_shpool->mutex);
|
158
|
+
ngx_http_push_store_reserve_message_locked(channel, msg);
|
159
|
+
ngx_shmtx_unlock(&ngx_http_push_shpool->mutex);
|
160
|
+
//we need a refcount because channel messages MAY be dequed before they are used up. It thus falls on the IPC stuff to free it.
|
161
|
+
}
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
//free memory for a message.
|
166
|
+
static ngx_inline void ngx_http_push_free_message_locked(ngx_http_push_msg_t *msg, ngx_slab_pool_t *shpool) {
|
167
|
+
if(msg->buf->file!=NULL) {
|
168
|
+
// i'd like to release the shpool lock here while i do stuff to this file, but that
|
169
|
+
// might unlock during channel rbtree traversal, which is Bad News.
|
170
|
+
if(msg->buf->file->fd!=NGX_INVALID_FILE) {
|
171
|
+
ngx_close_file(msg->buf->file->fd);
|
172
|
+
}
|
173
|
+
ngx_delete_file(msg->buf->file->name.data); //should I care about deletion errors? doubt it.
|
174
|
+
}
|
175
|
+
ngx_http_push_slab_free_locked(msg->buf); //separate block, remember?
|
176
|
+
ngx_http_push_slab_free_locked(msg);
|
177
|
+
//ngx_log_error(NGX_LOG_WARN, ngx_cycle->log, 0, FREED_DBG, msg, msg->refcount, msg->queue.prev, msg->queue.next);
|
178
|
+
if(msg->refcount < 0) { //something worth exploring went wrong
|
179
|
+
raise(SIGSEGV);
|
180
|
+
}
|
181
|
+
((ngx_http_push_shm_data_t *) ngx_http_push_shm_zone->data)->messages--;
|
182
|
+
}
|
183
|
+
|
184
|
+
// remove a message from queue and free all associated memory. assumes shpool is already locked.
|
185
|
+
static ngx_int_t ngx_http_push_delete_message_locked(ngx_http_push_channel_t *channel, ngx_http_push_msg_t *msg, ngx_int_t force) {
|
186
|
+
if (msg==NULL) {
|
187
|
+
return NGX_OK;
|
188
|
+
}
|
189
|
+
if(channel!=NULL) {
|
190
|
+
ngx_queue_remove(&msg->queue);
|
191
|
+
channel->messages--;
|
192
|
+
}
|
193
|
+
if(msg->refcount<=0 || force) {
|
194
|
+
//nobody needs this message, or we were forced at integer-point to delete
|
195
|
+
ngx_http_push_free_message_locked(msg, ngx_http_push_shpool);
|
196
|
+
}
|
197
|
+
return NGX_OK;
|
198
|
+
}
|
199
|
+
|
200
|
+
static void ngx_http_push_store_release_message_locked(ngx_http_push_channel_t *channel, ngx_http_push_msg_t *msg) {
|
201
|
+
if(msg == NULL) {
|
202
|
+
return;
|
203
|
+
}
|
204
|
+
msg->refcount--;
|
205
|
+
//ngx_log_error(NGX_LOG_WARN, ngx_cycle->log, 0, RELEASED_DBG, msg, msg->refcount, msg->queue.prev, msg->queue.next);
|
206
|
+
if(msg->queue.next==NULL && msg->refcount<=0) {
|
207
|
+
//message had been dequeued and nobody needs it anymore
|
208
|
+
ngx_http_push_free_message_locked(msg, ngx_http_push_shpool);
|
209
|
+
}
|
210
|
+
if(channel != NULL && channel->messages > msg->delete_oldest_received_min_messages && ngx_http_push_get_oldest_message_locked(channel) == msg) {
|
211
|
+
ngx_http_push_delete_message_locked(channel, msg, 0);
|
212
|
+
}
|
213
|
+
}
|
214
|
+
|
215
|
+
static void ngx_http_push_store_release_message(ngx_http_push_channel_t *channel, ngx_http_push_msg_t *msg) {
|
216
|
+
ngx_shmtx_lock(&ngx_http_push_shpool->mutex);
|
217
|
+
ngx_http_push_store_release_message_locked(channel, msg);
|
218
|
+
ngx_shmtx_unlock(&ngx_http_push_shpool->mutex);
|
219
|
+
}
|
220
|
+
|
221
|
+
static ngx_int_t ngx_http_push_delete_message(ngx_http_push_channel_t *channel, ngx_http_push_msg_t *msg, ngx_int_t force) {
|
222
|
+
ngx_int_t ret;
|
223
|
+
ngx_shmtx_lock(&ngx_http_push_shpool->mutex);
|
224
|
+
ret = ngx_http_push_delete_message_locked(channel, msg, force);
|
225
|
+
ngx_shmtx_unlock(&ngx_http_push_shpool->mutex);
|
226
|
+
return ret;
|
227
|
+
}
|
228
|
+
|
229
|
+
|
230
|
+
/** find message with entity tags matching those of the request r.
|
231
|
+
* @param r subscriber request
|
232
|
+
*/
|
233
|
+
static ngx_http_push_msg_t * ngx_http_push_find_message_locked(ngx_http_push_channel_t *channel, ngx_http_push_msg_id_t *msgid, ngx_int_t *status) {
|
234
|
+
//TODO: consider using an RBTree for message storage.
|
235
|
+
ngx_queue_t *sentinel = &channel->message_queue->queue;
|
236
|
+
ngx_queue_t *cur = ngx_queue_head(sentinel);
|
237
|
+
ngx_http_push_msg_t *msg;
|
238
|
+
|
239
|
+
time_t time = msgid->time;
|
240
|
+
ngx_int_t tag = msgid->tag;
|
241
|
+
|
242
|
+
//channel's message buffer empty?
|
243
|
+
if(channel->messages==0) {
|
244
|
+
*status=NGX_HTTP_PUSH_MESSAGE_EXPECTED; //wait.
|
245
|
+
return NULL;
|
246
|
+
}
|
247
|
+
|
248
|
+
// do we want a future message?
|
249
|
+
msg = ngx_queue_data(sentinel->prev, ngx_http_push_msg_t, queue);
|
250
|
+
if(time <= msg->message_time) { //that's an empty check (Sentinel's values are zero)
|
251
|
+
if(time == msg->message_time) {
|
252
|
+
if(tag >= msg->message_tag) {
|
253
|
+
*status=NGX_HTTP_PUSH_MESSAGE_EXPECTED;
|
254
|
+
return NULL;
|
255
|
+
}
|
256
|
+
}
|
257
|
+
}
|
258
|
+
else {
|
259
|
+
*status=NGX_HTTP_PUSH_MESSAGE_EXPECTED;
|
260
|
+
return NULL;
|
261
|
+
}
|
262
|
+
|
263
|
+
while(cur!=sentinel) {
|
264
|
+
msg = ngx_queue_data(cur, ngx_http_push_msg_t, queue);
|
265
|
+
if (time < msg->message_time) {
|
266
|
+
*status = NGX_HTTP_PUSH_MESSAGE_FOUND;
|
267
|
+
return msg;
|
268
|
+
}
|
269
|
+
else if(time == msg->message_time) {
|
270
|
+
while (tag >= msg->message_tag && time == msg->message_time && ngx_queue_next(cur)!=sentinel) {
|
271
|
+
cur=ngx_queue_next(cur);
|
272
|
+
msg = ngx_queue_data(cur, ngx_http_push_msg_t, queue);
|
273
|
+
}
|
274
|
+
if(time == msg->message_time && tag < msg->message_tag) {
|
275
|
+
*status = NGX_HTTP_PUSH_MESSAGE_FOUND;
|
276
|
+
return msg;
|
277
|
+
}
|
278
|
+
continue;
|
279
|
+
}
|
280
|
+
cur=ngx_queue_next(cur);
|
281
|
+
}
|
282
|
+
*status = NGX_HTTP_PUSH_MESSAGE_EXPIRED; //message too old and was not found.
|
283
|
+
return NULL;
|
284
|
+
}
|
285
|
+
|
286
|
+
static ngx_http_push_channel_t * ngx_http_push_store_find_channel(ngx_str_t *id, time_t channel_timeout, ngx_int_t (*callback)(ngx_http_push_channel_t *channel)) {
|
287
|
+
//get the channel and check channel authorization while we're at it.
|
288
|
+
ngx_http_push_channel_t *channel;
|
289
|
+
ngx_shmtx_lock(&ngx_http_push_shpool->mutex);
|
290
|
+
channel = ngx_http_push_find_channel(id, channel_timeout, ngx_http_push_shm_zone);
|
291
|
+
ngx_shmtx_unlock(&ngx_http_push_shpool->mutex);
|
292
|
+
if(callback!=NULL) {
|
293
|
+
callback(channel);
|
294
|
+
}
|
295
|
+
return channel;
|
296
|
+
}
|
297
|
+
|
298
|
+
//temporary cheat
|
299
|
+
static ngx_int_t ngx_http_push_store_publish_raw(ngx_http_push_channel_t *channel, ngx_http_push_msg_t *msg, ngx_int_t status_code, const ngx_str_t *status_line) {
|
300
|
+
|
301
|
+
//subscribers are queued up in a local pool. Queue heads, however, are located
|
302
|
+
//in shared memory, identified by pid.
|
303
|
+
ngx_shmtx_lock(&ngx_http_push_shpool->mutex);
|
304
|
+
ngx_http_push_pid_queue_t *sentinel = channel->workers_with_subscribers;
|
305
|
+
ngx_http_push_subscriber_t *subscriber_sentinels[NGX_MAX_PROCESSES];
|
306
|
+
ngx_http_push_pid_queue_t *pid_queues[NGX_MAX_PROCESSES];
|
307
|
+
ngx_int_t sub_sentinel_count=0;
|
308
|
+
|
309
|
+
ngx_http_push_pid_queue_t *cur;
|
310
|
+
ngx_int_t i, received;
|
311
|
+
received = channel->subscribers > 0 ? NGX_HTTP_PUSH_MESSAGE_RECEIVED : NGX_HTTP_PUSH_MESSAGE_QUEUED;
|
312
|
+
|
313
|
+
//we need to reserve the message for all the workers in advance
|
314
|
+
for(cur=(ngx_http_push_pid_queue_t *)ngx_queue_next(&sentinel->queue); cur != sentinel; cur=(ngx_http_push_pid_queue_t *)ngx_queue_next(&cur->queue)) {
|
315
|
+
if(cur->subscriber_sentinel != NULL) {
|
316
|
+
pid_queues[sub_sentinel_count] = cur;
|
317
|
+
subscriber_sentinels[sub_sentinel_count] = cur->subscriber_sentinel;
|
318
|
+
/*
|
319
|
+
* each time all of a worker's subscribers are removed, so is the sentinel.
|
320
|
+
* this is done to make garbage collection easier. Assuming we want to avoid
|
321
|
+
* placing the sentinel in shared memory (for now -- it's a little tricky
|
322
|
+
* to debug), the owner of the worker pool must be the one to free said sentinel.
|
323
|
+
* But channels may be deleted by different worker processes, and it seems unwieldy
|
324
|
+
* (for now) to do IPC just to delete one stinkin' sentinel. Hence a new sentinel
|
325
|
+
* is used every time the subscriber queue is emptied.
|
326
|
+
*/
|
327
|
+
cur->subscriber_sentinel = NULL; //think about it it terms of garbage collection. it'll make sense. sort of.
|
328
|
+
sub_sentinel_count++;
|
329
|
+
}
|
330
|
+
}
|
331
|
+
if(sub_sentinel_count > 0) {
|
332
|
+
ngx_http_push_store_reserve_message_num_locked(channel, msg, sub_sentinel_count);
|
333
|
+
}
|
334
|
+
ngx_shmtx_unlock(&ngx_http_push_shpool->mutex);
|
335
|
+
|
336
|
+
ngx_http_push_subscriber_t *subscriber_sentinel=NULL;
|
337
|
+
for(i=0; i < sub_sentinel_count; i++) {
|
338
|
+
ngx_shmtx_lock(&ngx_http_push_shpool->mutex);
|
339
|
+
subscriber_sentinel = subscriber_sentinels[i];
|
340
|
+
pid_t worker_pid = pid_queues[i]->pid;
|
341
|
+
ngx_int_t worker_slot = pid_queues[i]->slot;
|
342
|
+
ngx_shmtx_unlock(&ngx_http_push_shpool->mutex);
|
343
|
+
//if(msg != NULL)
|
344
|
+
// ngx_log_error(NGX_LOG_WARN, ngx_cycle->log, 0, "publish msg %p (ref: %i) for worker %i (slot %i)", msg, msg->refcount, worker_pid, worker_slot);
|
345
|
+
|
346
|
+
|
347
|
+
if(subscriber_sentinel != NULL) {
|
348
|
+
if(worker_pid == ngx_pid) {
|
349
|
+
//my subscribers
|
350
|
+
ngx_http_push_respond_to_subscribers(channel, subscriber_sentinel, msg, status_code, status_line);
|
351
|
+
}
|
352
|
+
else {
|
353
|
+
//some other worker's subscribers
|
354
|
+
//interprocess communication breakdown
|
355
|
+
if(ngx_http_push_store_send_worker_message(channel, subscriber_sentinel, worker_pid, worker_slot, msg, status_code) != NGX_ERROR) {
|
356
|
+
ngx_http_push_alert_worker(worker_pid, worker_slot);
|
357
|
+
}
|
358
|
+
else {
|
359
|
+
ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0, "push module: error communicating with some other worker process");
|
360
|
+
}
|
361
|
+
}
|
362
|
+
} else {
|
363
|
+
//ngx_log_error(NGX_LOG_WARN, ngx_cycle->log, 0, "subscriber sentinel is NULL");
|
364
|
+
}
|
365
|
+
|
366
|
+
|
367
|
+
}
|
368
|
+
return received;
|
369
|
+
}
|
370
|
+
|
371
|
+
static ngx_int_t ngx_http_push_store_delete_channel(ngx_str_t *channel_id) {
|
372
|
+
ngx_http_push_channel_t *channel;
|
373
|
+
ngx_http_push_msg_t *msg, *sentinel;
|
374
|
+
ngx_http_push_store_lock_shmem();
|
375
|
+
channel = ngx_http_push_find_channel(channel_id, NGX_HTTP_PUSH_DEFAULT_CHANNEL_TIMEOUT, ngx_http_push_shm_zone);
|
376
|
+
if (channel == NULL) {
|
377
|
+
ngx_http_push_store_unlock_shmem();
|
378
|
+
return NGX_OK;
|
379
|
+
}
|
380
|
+
sentinel = channel->message_queue;
|
381
|
+
msg = sentinel;
|
382
|
+
|
383
|
+
while((msg=(ngx_http_push_msg_t *)ngx_queue_next(&msg->queue))!=sentinel) {
|
384
|
+
//force-delete all the messages
|
385
|
+
ngx_http_push_delete_message_locked(NULL, msg, 1);
|
386
|
+
}
|
387
|
+
channel->messages=0;
|
388
|
+
|
389
|
+
//410 gone
|
390
|
+
ngx_http_push_store_unlock_shmem();
|
391
|
+
|
392
|
+
ngx_http_push_store_publish_raw(channel, NULL, NGX_HTTP_GONE, &NGX_HTTP_PUSH_HTTP_STATUS_410);
|
393
|
+
|
394
|
+
ngx_http_push_store_lock_shmem();
|
395
|
+
ngx_http_push_delete_channel_locked(channel, ngx_http_push_shm_zone);
|
396
|
+
ngx_http_push_store_unlock_shmem();
|
397
|
+
return NGX_OK;
|
398
|
+
}
|
399
|
+
|
400
|
+
static ngx_http_push_channel_t * ngx_http_push_store_get_channel(ngx_str_t *id, time_t channel_timeout, ngx_int_t (*callback)(ngx_http_push_channel_t *channel)) {
|
401
|
+
//get the channel and check channel authorization while we're at it.
|
402
|
+
ngx_http_push_channel_t *channel;
|
403
|
+
ngx_shmtx_lock(&ngx_http_push_shpool->mutex);
|
404
|
+
channel = ngx_http_push_get_channel(id, channel_timeout, ngx_http_push_shm_zone);
|
405
|
+
ngx_shmtx_unlock(&ngx_http_push_shpool->mutex);
|
406
|
+
if(channel==NULL) {
|
407
|
+
ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0, "push module: unable to allocate memory for new channel");
|
408
|
+
}
|
409
|
+
if(callback!=NULL) {
|
410
|
+
callback(channel);
|
411
|
+
}
|
412
|
+
return channel;
|
413
|
+
}
|
414
|
+
|
415
|
+
static ngx_http_push_msg_t * ngx_http_push_store_get_channel_message(ngx_http_push_channel_t *channel, ngx_http_push_msg_id_t *msgid, ngx_int_t *msg_search_outcome, ngx_http_push_loc_conf_t *cf) {
|
416
|
+
ngx_http_push_msg_t *msg;
|
417
|
+
ngx_shmtx_lock(&ngx_http_push_shpool->mutex);
|
418
|
+
msg = ngx_http_push_find_message_locked(channel, msgid, msg_search_outcome);
|
419
|
+
if(*msg_search_outcome == NGX_HTTP_PUSH_MESSAGE_FOUND) {
|
420
|
+
ngx_http_push_store_reserve_message_locked(channel, msg);
|
421
|
+
}
|
422
|
+
channel->last_seen = ngx_time();
|
423
|
+
channel->expires = ngx_time() + cf->channel_timeout;
|
424
|
+
ngx_shmtx_unlock(&ngx_http_push_shpool->mutex);
|
425
|
+
return msg;
|
426
|
+
}
|
427
|
+
|
428
|
+
static ngx_int_t default_get_message_callback(ngx_http_push_msg_t *msg, ngx_int_t msg_search_outcome, ngx_http_request_t *r) {
|
429
|
+
return NGX_OK;
|
430
|
+
}
|
431
|
+
|
432
|
+
static ngx_http_push_msg_t * ngx_http_push_store_get_message(ngx_str_t *channel_id, ngx_http_push_msg_id_t *msg_id, ngx_int_t *msg_search_outcome, ngx_http_request_t *r, ngx_int_t (*callback)(ngx_http_push_msg_t *msg, ngx_int_t msg_search_outcome, ngx_http_request_t *r)) {
|
433
|
+
ngx_http_push_channel_t *channel;
|
434
|
+
ngx_http_push_msg_t *msg;
|
435
|
+
if(callback==NULL) {
|
436
|
+
callback=&default_get_message_callback;
|
437
|
+
}
|
438
|
+
ngx_http_push_store_lock_shmem();
|
439
|
+
channel = ngx_http_push_get_channel(channel_id, NGX_HTTP_PUSH_DEFAULT_CHANNEL_TIMEOUT, ngx_http_push_shm_zone);
|
440
|
+
ngx_http_push_store_unlock_shmem();
|
441
|
+
if (channel == NULL) {
|
442
|
+
return NULL;
|
443
|
+
}
|
444
|
+
msg = ngx_http_push_store_get_channel_message(channel, msg_id, msg_search_outcome, ngx_http_get_module_loc_conf(r, ngx_http_push_module));
|
445
|
+
callback(msg, *msg_search_outcome, r);
|
446
|
+
return msg;
|
447
|
+
}
|
448
|
+
|
449
|
+
// shared memory zone initializer
|
450
|
+
static ngx_int_t ngx_http_push_init_shm_zone(ngx_shm_zone_t * shm_zone, void *data) {
|
451
|
+
if(data) { /* zone already initialized */
|
452
|
+
shm_zone->data = data;
|
453
|
+
return NGX_OK;
|
454
|
+
}
|
455
|
+
|
456
|
+
ngx_slab_pool_t *shpool = (ngx_slab_pool_t *) shm_zone->shm.addr;
|
457
|
+
ngx_rbtree_node_t *sentinel;
|
458
|
+
ngx_http_push_shm_data_t *d;
|
459
|
+
|
460
|
+
ngx_http_push_shpool = shpool; //we'll be using this a bit.
|
461
|
+
#if (DEBUG_SHM_ALLOC == 1)
|
462
|
+
ngx_log_error(NGX_LOG_WARN, ngx_cycle->log, 0, "ngx_http_push_shpool start %p size %i", shpool->start, (u_char *)shpool->end - (u_char *)shpool->start);
|
463
|
+
#endif
|
464
|
+
|
465
|
+
if ((d = (ngx_http_push_shm_data_t *)ngx_http_push_slab_alloc(sizeof(*d), "shm data")) == NULL) { //shm_data
|
466
|
+
return NGX_ERROR;
|
467
|
+
}
|
468
|
+
d->channels=0;
|
469
|
+
d->messages=0;
|
470
|
+
shm_zone->data = d;
|
471
|
+
d->ipc=NULL;
|
472
|
+
//initialize rbtree
|
473
|
+
if ((sentinel = ngx_http_push_slab_alloc(sizeof(*sentinel), "channel rbtree sentinel"))==NULL) {
|
474
|
+
return NGX_ERROR;
|
475
|
+
}
|
476
|
+
ngx_rbtree_init(&d->tree, sentinel, ngx_http_push_rbtree_insert);
|
477
|
+
return NGX_OK;
|
478
|
+
}
|
479
|
+
|
480
|
+
//shared memory
|
481
|
+
static ngx_str_t ngx_push_shm_name = ngx_string("push_module"); //shared memory segment name
|
482
|
+
static ngx_int_t ngx_http_push_set_up_shm(ngx_conf_t *cf, size_t shm_size) {
|
483
|
+
ngx_http_push_shm_zone = ngx_shared_memory_add(cf, &ngx_push_shm_name, shm_size, &ngx_http_push_module);
|
484
|
+
if (ngx_http_push_shm_zone == NULL) {
|
485
|
+
return NGX_ERROR;
|
486
|
+
}
|
487
|
+
ngx_http_push_shm_zone->init = ngx_http_push_init_shm_zone;
|
488
|
+
ngx_http_push_shm_zone->data = (void *) 1;
|
489
|
+
return NGX_OK;
|
490
|
+
}
|
491
|
+
|
492
|
+
//initialization
|
493
|
+
static ngx_int_t ngx_http_push_store_init_module(ngx_cycle_t *cycle) {
|
494
|
+
ngx_core_conf_t *ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
|
495
|
+
ngx_http_push_worker_processes = ccf->worker_processes;
|
496
|
+
//initialize our little IPC
|
497
|
+
return ngx_http_push_init_ipc(cycle, ngx_http_push_worker_processes);
|
498
|
+
}
|
499
|
+
|
500
|
+
//will be called once per worker
|
501
|
+
static ngx_int_t ngx_http_push_store_init_ipc_shm(ngx_int_t workers) {
|
502
|
+
ngx_slab_pool_t *shpool = (ngx_slab_pool_t *) ngx_http_push_shm_zone->shm.addr;
|
503
|
+
ngx_http_push_shm_data_t *d = (ngx_http_push_shm_data_t *) ngx_http_push_shm_zone->data;
|
504
|
+
ngx_http_push_worker_msg_sentinel_t *worker_messages=NULL;
|
505
|
+
ngx_shmtx_lock(&shpool->mutex);
|
506
|
+
if(d->ipc==NULL) {
|
507
|
+
//ipc uninitialized. get it done!
|
508
|
+
if((worker_messages = ngx_http_push_slab_alloc_locked(sizeof(*worker_messages)*NGX_MAX_PROCESSES, "IPC worker message sentinel array"))==NULL) {
|
509
|
+
ngx_shmtx_unlock(&shpool->mutex);
|
510
|
+
return NGX_ERROR;
|
511
|
+
}
|
512
|
+
d->ipc=worker_messages;
|
513
|
+
}
|
514
|
+
else {
|
515
|
+
worker_messages=d->ipc;
|
516
|
+
}
|
517
|
+
|
518
|
+
ngx_queue_init(&worker_messages[ngx_process_slot].queue);
|
519
|
+
ngx_rwlock_init(&worker_messages[ngx_process_slot].lock);
|
520
|
+
|
521
|
+
ngx_shmtx_unlock(&shpool->mutex);
|
522
|
+
return NGX_OK;
|
523
|
+
}
|
524
|
+
|
525
|
+
static ngx_int_t ngx_http_push_store_init_worker(ngx_cycle_t *cycle) {
|
526
|
+
ngx_core_conf_t *ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
|
527
|
+
if(ngx_http_push_store_init_ipc_shm(ccf->worker_processes) == NGX_OK) {
|
528
|
+
return ngx_http_push_ipc_init_worker(cycle);
|
529
|
+
}
|
530
|
+
else {
|
531
|
+
return NGX_ERROR;
|
532
|
+
}
|
533
|
+
}
|
534
|
+
|
535
|
+
static ngx_int_t ngx_http_push_store_init_postconfig(ngx_conf_t *cf) {
|
536
|
+
ngx_http_push_main_conf_t *conf = ngx_http_conf_get_module_main_conf(cf, ngx_http_push_module);
|
537
|
+
|
538
|
+
//initialize shared memory
|
539
|
+
size_t shm_size;
|
540
|
+
if(conf->shm_size==NGX_CONF_UNSET_SIZE) {
|
541
|
+
conf->shm_size=NGX_HTTP_PUSH_DEFAULT_SHM_SIZE;
|
542
|
+
}
|
543
|
+
shm_size = ngx_align(conf->shm_size, ngx_pagesize);
|
544
|
+
if (shm_size < 8 * ngx_pagesize) {
|
545
|
+
ngx_conf_log_error(NGX_LOG_WARN, cf, 0, "The push_max_reserved_memory value must be at least %udKiB", (8 * ngx_pagesize) >> 10);
|
546
|
+
shm_size = 8 * ngx_pagesize;
|
547
|
+
}
|
548
|
+
if(ngx_http_push_shm_zone && ngx_http_push_shm_zone->shm.size != shm_size) {
|
549
|
+
ngx_conf_log_error(NGX_LOG_WARN, cf, 0, "Cannot change memory area size without restart, ignoring change");
|
550
|
+
}
|
551
|
+
ngx_conf_log_error(NGX_LOG_INFO, cf, 0, "Using %udKiB of shared memory for push module", shm_size >> 10);
|
552
|
+
|
553
|
+
return ngx_http_push_set_up_shm(cf, shm_size);
|
554
|
+
}
|
555
|
+
|
556
|
+
static void ngx_http_push_store_create_main_conf(ngx_conf_t *cf, ngx_http_push_main_conf_t *mcf) {
|
557
|
+
mcf->shm_size=NGX_CONF_UNSET_SIZE;
|
558
|
+
}
|
559
|
+
|
560
|
+
//great justice appears to be at hand
|
561
|
+
static ngx_int_t ngx_http_push_movezig_channel_locked(ngx_http_push_channel_t * channel) {
|
562
|
+
ngx_queue_t *sentinel = &channel->message_queue->queue;
|
563
|
+
ngx_http_push_msg_t *msg=NULL;
|
564
|
+
while(!ngx_queue_empty(sentinel)) {
|
565
|
+
msg = ngx_queue_data(ngx_queue_head(sentinel), ngx_http_push_msg_t, queue);
|
566
|
+
ngx_http_push_delete_message_locked(channel, msg, 1);
|
567
|
+
}
|
568
|
+
return NGX_OK;
|
569
|
+
}
|
570
|
+
static ngx_int_t ngx_http_push_store_channel_subscribers(ngx_http_push_channel_t * channel) {
|
571
|
+
ngx_int_t subs;
|
572
|
+
ngx_shmtx_lock(&ngx_http_push_shpool->mutex);
|
573
|
+
subs = channel->subscribers;
|
574
|
+
ngx_shmtx_unlock(&ngx_http_push_shpool->mutex);
|
575
|
+
return subs;
|
576
|
+
}
|
577
|
+
|
578
|
+
static ngx_int_t ngx_http_push_store_channel_worker_subscribers(ngx_http_push_subscriber_t * worker_sentinel) {
|
579
|
+
ngx_http_push_subscriber_t *cur;
|
580
|
+
ngx_int_t count=0;
|
581
|
+
cur=(ngx_http_push_subscriber_t *)ngx_queue_head(&worker_sentinel->queue);
|
582
|
+
while(cur!=worker_sentinel) {
|
583
|
+
count++;
|
584
|
+
cur=(ngx_http_push_subscriber_t *)ngx_queue_next(&cur->queue);
|
585
|
+
}
|
586
|
+
return count;
|
587
|
+
}
|
588
|
+
|
589
|
+
static ngx_http_push_subscriber_t *ngx_http_push_store_channel_next_subscriber(ngx_http_push_channel_t *channel, ngx_http_push_subscriber_t *sentinel, ngx_http_push_subscriber_t *cur, int release_previous) {
|
590
|
+
ngx_http_push_subscriber_t *next;
|
591
|
+
if(cur==NULL) {
|
592
|
+
next=(ngx_http_push_subscriber_t *)ngx_queue_head(&sentinel->queue);
|
593
|
+
}
|
594
|
+
else{
|
595
|
+
next=(ngx_http_push_subscriber_t *)ngx_queue_next(&cur->queue);
|
596
|
+
if(release_previous==1 && cur!=sentinel) {
|
597
|
+
//ngx_log_error(NGX_LOG_WARN, ngx_cycle->log, 0, "freeing subscriber cursor at %p.", cur);
|
598
|
+
ngx_pfree(ngx_http_push_pool, cur);
|
599
|
+
}
|
600
|
+
}
|
601
|
+
return next!=sentinel ? next : NULL;
|
602
|
+
}
|
603
|
+
|
604
|
+
static ngx_int_t ngx_http_push_store_channel_release_subscriber_sentinel(ngx_http_push_channel_t *channel, ngx_http_push_subscriber_t *sentinel) {
|
605
|
+
//ngx_log_error(NGX_LOG_WARN, ngx_cycle->log, 0, "freeing subscriber sentinel at %p.", sentinel);
|
606
|
+
ngx_pfree(ngx_http_push_pool, sentinel);
|
607
|
+
return NGX_OK;
|
608
|
+
}
|
609
|
+
|
610
|
+
static void ngx_http_push_store_exit_worker(ngx_cycle_t *cycle) {
|
611
|
+
ngx_http_push_ipc_exit_worker(cycle);
|
612
|
+
}
|
613
|
+
|
614
|
+
static void ngx_http_push_store_exit_master(ngx_cycle_t *cycle) {
|
615
|
+
//destroy channel tree in shared memory
|
616
|
+
ngx_http_push_walk_rbtree(ngx_http_push_movezig_channel_locked, ngx_http_push_shm_zone);
|
617
|
+
//deinitialize IPC
|
618
|
+
ngx_http_push_shutdown_ipc(cycle);
|
619
|
+
}
|
620
|
+
|
621
|
+
static ngx_http_push_subscriber_t * ngx_http_push_store_subscribe_raw(ngx_http_push_channel_t *channel, ngx_http_request_t *r) {
|
622
|
+
ngx_http_push_pid_queue_t *sentinel, *cur, *found;
|
623
|
+
ngx_http_push_subscriber_t *subscriber;
|
624
|
+
ngx_http_push_subscriber_t *subscriber_sentinel;
|
625
|
+
//ngx_http_push_loc_conf_t *cf = ngx_http_get_module_loc_conf(r, ngx_http_push_module);
|
626
|
+
|
627
|
+
//subscribers are queued up in a local pool. Queue sentinels are separate and also local, but not in the pool.
|
628
|
+
ngx_shmtx_lock(&ngx_http_push_shpool->mutex);
|
629
|
+
sentinel = channel->workers_with_subscribers;
|
630
|
+
cur = (ngx_http_push_pid_queue_t *)ngx_queue_head(&sentinel->queue);
|
631
|
+
found = NULL;
|
632
|
+
|
633
|
+
while(cur!=sentinel) {
|
634
|
+
if(cur->pid==ngx_pid) {
|
635
|
+
found = cur;
|
636
|
+
break;
|
637
|
+
}
|
638
|
+
cur = (ngx_http_push_pid_queue_t *)ngx_queue_next(&cur->queue);
|
639
|
+
}
|
640
|
+
if(found == NULL) { //found nothing
|
641
|
+
if((found=ngx_http_push_slab_alloc_locked(sizeof(*found), "worker subscriber sentinel"))==NULL) {
|
642
|
+
ngx_shmtx_unlock(&ngx_http_push_shpool->mutex);
|
643
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "push module: unable to allocate worker subscriber queue marker in shared memory");
|
644
|
+
return NULL;
|
645
|
+
}
|
646
|
+
//initialize
|
647
|
+
ngx_queue_insert_tail(&sentinel->queue, &found->queue);
|
648
|
+
found->pid=ngx_pid;
|
649
|
+
found->slot=ngx_process_slot;
|
650
|
+
found->subscriber_sentinel=NULL;
|
651
|
+
}
|
652
|
+
if((subscriber = ngx_palloc(ngx_http_push_pool, sizeof(*subscriber)))==NULL) { //unable to allocate request queue element
|
653
|
+
ngx_shmtx_unlock(&ngx_http_push_shpool->mutex);
|
654
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "push module: unable to allocate subscriber worker's memory pool");
|
655
|
+
return NULL;
|
656
|
+
}
|
657
|
+
channel->subscribers++; // do this only when we know everything went okay.
|
658
|
+
|
659
|
+
//figure out the subscriber sentinel
|
660
|
+
subscriber_sentinel = ((ngx_http_push_pid_queue_t *)found)->subscriber_sentinel;
|
661
|
+
//ngx_log_error(NGX_LOG_WARN, ngx_cycle->log, 0, "reserve subscriber sentinel at %p", subscriber_sentinel);
|
662
|
+
|
663
|
+
if(subscriber_sentinel==NULL) {
|
664
|
+
//it's perfectly normal for the sentinel to be NULL.
|
665
|
+
if((subscriber_sentinel=ngx_palloc(ngx_http_push_pool, sizeof(*subscriber_sentinel)))==NULL) {
|
666
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "push module: unable to allocate channel subscriber sentinel");
|
667
|
+
return NULL;
|
668
|
+
}
|
669
|
+
ngx_queue_init(&subscriber_sentinel->queue);
|
670
|
+
((ngx_http_push_pid_queue_t *)found)->subscriber_sentinel=subscriber_sentinel;
|
671
|
+
}
|
672
|
+
//ngx_log_error(NGX_LOG_WARN, ngx_cycle->log, 0, "add to subscriber sentinel at %p", subscriber_sentinel);
|
673
|
+
ngx_queue_insert_tail(&subscriber_sentinel->queue, &subscriber->queue);
|
674
|
+
ngx_shmtx_unlock(&ngx_http_push_shpool->mutex);
|
675
|
+
|
676
|
+
subscriber->request = r;
|
677
|
+
return subscriber;
|
678
|
+
}
|
679
|
+
|
680
|
+
static ngx_int_t ngx_http_push_handle_subscriber_concurrency(ngx_http_push_channel_t *channel, ngx_http_request_t *r, ngx_http_push_loc_conf_t *cf) {
|
681
|
+
ngx_int_t max_subscribers = cf->max_channel_subscribers;
|
682
|
+
ngx_int_t current_subscribers = ngx_http_push_store->channel_subscribers(channel) ;
|
683
|
+
|
684
|
+
|
685
|
+
if(current_subscribers==0) {
|
686
|
+
//empty channels are always okay.
|
687
|
+
return NGX_OK;
|
688
|
+
}
|
689
|
+
|
690
|
+
if(max_subscribers!=0 && current_subscribers >= max_subscribers) {
|
691
|
+
//max_channel_subscribers setting
|
692
|
+
ngx_http_push_respond_status_only(r, NGX_HTTP_FORBIDDEN, NULL);
|
693
|
+
return NGX_DECLINED;
|
694
|
+
}
|
695
|
+
|
696
|
+
//nonzero number of subscribers present
|
697
|
+
switch(cf->subscriber_concurrency) {
|
698
|
+
case NGX_HTTP_PUSH_SUBSCRIBER_CONCURRENCY_BROADCAST:
|
699
|
+
return NGX_OK;
|
700
|
+
|
701
|
+
case NGX_HTTP_PUSH_SUBSCRIBER_CONCURRENCY_LASTIN:
|
702
|
+
//send "everyone" a 409 Conflict response.
|
703
|
+
//in most reasonable cases, there'll be at most one subscriber on the
|
704
|
+
//channel. However, since settings are bound to locations and not
|
705
|
+
//specific channels, this assumption need not hold. Hence this broadcast.
|
706
|
+
ngx_http_push_store_publish_raw(channel, NULL, NGX_HTTP_NOT_FOUND, &NGX_HTTP_PUSH_HTTP_STATUS_409);
|
707
|
+
|
708
|
+
return NGX_OK;
|
709
|
+
|
710
|
+
case NGX_HTTP_PUSH_SUBSCRIBER_CONCURRENCY_FIRSTIN:
|
711
|
+
ngx_http_push_respond_status_only(r, NGX_HTTP_NOT_FOUND, &NGX_HTTP_PUSH_HTTP_STATUS_409);
|
712
|
+
return NGX_DECLINED;
|
713
|
+
|
714
|
+
default:
|
715
|
+
return NGX_ERROR;
|
716
|
+
}
|
717
|
+
}
|
718
|
+
|
719
|
+
static ngx_int_t default_subscribe_callback(ngx_int_t status, ngx_http_request_t *r) {
|
720
|
+
return status;
|
721
|
+
}
|
722
|
+
|
723
|
+
static ngx_int_t ngx_http_push_store_subscribe(ngx_str_t *channel_id, ngx_http_push_msg_id_t *msg_id, ngx_http_request_t *r, ngx_int_t (*callback)(ngx_int_t status, ngx_http_request_t *r)) {
|
724
|
+
ngx_http_push_channel_t *channel;
|
725
|
+
ngx_http_push_msg_t *msg;
|
726
|
+
ngx_int_t msg_search_outcome;
|
727
|
+
ngx_http_push_loc_conf_t *cf = ngx_http_get_module_loc_conf(r, ngx_http_push_module);
|
728
|
+
|
729
|
+
|
730
|
+
if(callback == NULL) {
|
731
|
+
callback=&default_subscribe_callback;
|
732
|
+
}
|
733
|
+
|
734
|
+
if (cf->authorize_channel==1) {
|
735
|
+
channel = ngx_http_push_store_find_channel(channel_id, cf->channel_timeout, NULL);
|
736
|
+
}else{
|
737
|
+
channel = ngx_http_push_store_get_channel(channel_id, cf->channel_timeout, NULL);
|
738
|
+
}
|
739
|
+
if (channel==NULL) {
|
740
|
+
//unable to allocate channel OR channel not found
|
741
|
+
if(cf->authorize_channel) {
|
742
|
+
return callback(NGX_HTTP_FORBIDDEN, r);
|
743
|
+
}
|
744
|
+
else {
|
745
|
+
ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0, "push module: unable to allocate shared memory for channel");
|
746
|
+
return callback(NGX_HTTP_INTERNAL_SERVER_ERROR, r);
|
747
|
+
}
|
748
|
+
}
|
749
|
+
|
750
|
+
switch(ngx_http_push_handle_subscriber_concurrency(channel, r, cf)) {
|
751
|
+
case NGX_DECLINED: //this request was declined for some reason.
|
752
|
+
//status codes and whatnot should have already been written. just get out of here quickly.
|
753
|
+
return callback(NGX_OK, r);
|
754
|
+
case NGX_ERROR:
|
755
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "push module: error handling subscriber concurrency setting");
|
756
|
+
return callback(NGX_ERROR, r);
|
757
|
+
}
|
758
|
+
|
759
|
+
|
760
|
+
msg = ngx_http_push_store->get_channel_message(channel, msg_id, &msg_search_outcome, cf);
|
761
|
+
|
762
|
+
if (cf->ignore_queue_on_no_cache && !ngx_http_push_allow_caching(r)) {
|
763
|
+
msg_search_outcome = NGX_HTTP_PUSH_MESSAGE_EXPECTED;
|
764
|
+
msg = NULL;
|
765
|
+
}
|
766
|
+
|
767
|
+
switch(msg_search_outcome) {
|
768
|
+
//for message-found:
|
769
|
+
ngx_str_t *etag;
|
770
|
+
ngx_str_t *content_type;
|
771
|
+
ngx_chain_t *chain;
|
772
|
+
time_t last_modified;
|
773
|
+
ngx_http_push_subscriber_t *subscriber;
|
774
|
+
|
775
|
+
case NGX_HTTP_PUSH_MESSAGE_EXPECTED:
|
776
|
+
// ♫ It's gonna be the future soon ♫
|
777
|
+
if ((subscriber = ngx_http_push_store_subscribe_raw(channel, r))==NULL) {
|
778
|
+
return callback(NGX_HTTP_INTERNAL_SERVER_ERROR, r);
|
779
|
+
}
|
780
|
+
if(ngx_push_longpoll_subscriber_enqueue(channel, subscriber, cf->subscriber_timeout) == NGX_OK) {
|
781
|
+
return callback(NGX_DONE, r);
|
782
|
+
}
|
783
|
+
else {
|
784
|
+
return callback(NGX_ERROR, r);
|
785
|
+
}
|
786
|
+
|
787
|
+
case NGX_HTTP_PUSH_MESSAGE_EXPIRED:
|
788
|
+
//subscriber wants an expired message
|
789
|
+
//TODO: maybe respond with entity-identifiers for oldest available message?
|
790
|
+
return callback(NGX_HTTP_NO_CONTENT, r);
|
791
|
+
|
792
|
+
case NGX_HTTP_PUSH_MESSAGE_FOUND:
|
793
|
+
ngx_http_push_alloc_for_subscriber_response(r->pool, 0, msg, &chain, &content_type, &etag, &last_modified);
|
794
|
+
ngx_int_t ret=ngx_http_push_prepare_response_to_subscriber_request(r, chain, content_type, etag, last_modified);
|
795
|
+
ngx_http_push_store->release_message(channel, msg);
|
796
|
+
return callback(ret, r);
|
797
|
+
|
798
|
+
default: //we shouldn't be here.
|
799
|
+
return callback(NGX_HTTP_INTERNAL_SERVER_ERROR, r);
|
800
|
+
}
|
801
|
+
}
|
802
|
+
|
803
|
+
static ngx_str_t * ngx_http_push_store_etag_from_message(ngx_http_push_msg_t *msg, ngx_pool_t *pool){
|
804
|
+
ngx_str_t *etag = NULL;
|
805
|
+
ngx_shmtx_lock(&ngx_http_push_shpool->mutex);
|
806
|
+
if(pool!=NULL && (etag = ngx_palloc(pool, sizeof(*etag) + NGX_INT_T_LEN))==NULL) {
|
807
|
+
return NULL;
|
808
|
+
}
|
809
|
+
else if(pool==NULL && (etag = ngx_alloc(sizeof(*etag) + NGX_INT_T_LEN, ngx_cycle->log))==NULL) {
|
810
|
+
return NULL;
|
811
|
+
}
|
812
|
+
etag->data = (u_char *)(etag+1);
|
813
|
+
etag->len = ngx_sprintf(etag->data,"%ui", msg->message_tag)- etag->data;
|
814
|
+
ngx_shmtx_unlock(&ngx_http_push_shpool->mutex);
|
815
|
+
return etag;
|
816
|
+
}
|
817
|
+
|
818
|
+
static ngx_str_t * ngx_http_push_store_content_type_from_message(ngx_http_push_msg_t *msg, ngx_pool_t *pool){
|
819
|
+
ngx_str_t *content_type = NULL;
|
820
|
+
ngx_shmtx_lock(&ngx_http_push_shpool->mutex);
|
821
|
+
if(pool != NULL && (content_type = ngx_palloc(pool, sizeof(*content_type) + msg->content_type.len))==NULL) {
|
822
|
+
return NULL;
|
823
|
+
}
|
824
|
+
else if(pool == NULL && (content_type = ngx_alloc(sizeof(*content_type) + msg->content_type.len, ngx_cycle->log))==NULL) {
|
825
|
+
return NULL;
|
826
|
+
}
|
827
|
+
content_type->data = (u_char *)(content_type+1);
|
828
|
+
content_type->len = msg->content_type.len;
|
829
|
+
ngx_memcpy(content_type->data, msg->content_type.data, content_type->len);
|
830
|
+
ngx_shmtx_unlock(&ngx_http_push_shpool->mutex);
|
831
|
+
return content_type;
|
832
|
+
}
|
833
|
+
|
834
|
+
// this function adapted from push stream module. thanks Wandenberg Peixoto <wandenberg@gmail.com> and Rogério Carvalho Schneider <stockrt@gmail.com>
|
835
|
+
static ngx_buf_t * ngx_http_push_request_body_to_single_buffer(ngx_http_request_t *r) {
|
836
|
+
ngx_buf_t *buf = NULL;
|
837
|
+
ngx_chain_t *chain;
|
838
|
+
ssize_t n;
|
839
|
+
off_t len;
|
840
|
+
|
841
|
+
chain = r->request_body->bufs;
|
842
|
+
if (chain->next == NULL) {
|
843
|
+
return chain->buf;
|
844
|
+
}
|
845
|
+
if (chain->buf->in_file) {
|
846
|
+
if (ngx_buf_in_memory(chain->buf)) {
|
847
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "push module: can't handle a buffer in a temp file and in memory ");
|
848
|
+
}
|
849
|
+
if (chain->next != NULL) {
|
850
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "push module: error reading request body with multiple ");
|
851
|
+
}
|
852
|
+
return chain->buf;
|
853
|
+
}
|
854
|
+
buf = ngx_create_temp_buf(r->pool, r->headers_in.content_length_n + 1);
|
855
|
+
if (buf != NULL) {
|
856
|
+
ngx_memset(buf->start, '\0', r->headers_in.content_length_n + 1);
|
857
|
+
while ((chain != NULL) && (chain->buf != NULL)) {
|
858
|
+
len = ngx_buf_size(chain->buf);
|
859
|
+
// if buffer is equal to content length all the content is in this buffer
|
860
|
+
if (len >= r->headers_in.content_length_n) {
|
861
|
+
buf->start = buf->pos;
|
862
|
+
buf->last = buf->pos;
|
863
|
+
len = r->headers_in.content_length_n;
|
864
|
+
}
|
865
|
+
if (chain->buf->in_file) {
|
866
|
+
n = ngx_read_file(chain->buf->file, buf->start, len, 0);
|
867
|
+
if (n == NGX_FILE_ERROR) {
|
868
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "push module: cannot read file with request body");
|
869
|
+
return NULL;
|
870
|
+
}
|
871
|
+
buf->last = buf->last + len;
|
872
|
+
ngx_delete_file(chain->buf->file->name.data);
|
873
|
+
chain->buf->file->fd = NGX_INVALID_FILE;
|
874
|
+
} else {
|
875
|
+
buf->last = ngx_copy(buf->start, chain->buf->pos, len);
|
876
|
+
}
|
877
|
+
|
878
|
+
chain = chain->next;
|
879
|
+
buf->start = buf->last;
|
880
|
+
}
|
881
|
+
}
|
882
|
+
return buf;
|
883
|
+
}
|
884
|
+
|
885
|
+
|
886
|
+
static ngx_http_push_msg_t * ngx_http_push_store_create_message(ngx_http_push_channel_t *channel, ngx_http_request_t *r) {
|
887
|
+
ngx_buf_t *buf = NULL, *buf_copy;
|
888
|
+
size_t content_type_len;
|
889
|
+
ngx_http_push_loc_conf_t *cf = ngx_http_get_module_loc_conf(r, ngx_http_push_module);
|
890
|
+
ngx_http_push_msg_t *msg, *previous_msg;
|
891
|
+
|
892
|
+
//first off, we'll want to extract the body buffer
|
893
|
+
|
894
|
+
//note: this works mostly because of r->request_body_in_single_buf = 1;
|
895
|
+
//which, i suppose, makes this module a little slower than it could be.
|
896
|
+
//this block is a little hacky. might be a thorn for forward-compatibility.
|
897
|
+
if(r->headers_in.content_length_n == -1 || r->headers_in.content_length_n == 0) {
|
898
|
+
buf = ngx_create_temp_buf(r->pool, 0);
|
899
|
+
//this buffer will get copied to shared memory in a few lines,
|
900
|
+
//so it does't matter what pool we make it in.
|
901
|
+
}
|
902
|
+
else if(r->request_body->bufs!=NULL) {
|
903
|
+
buf = ngx_http_push_request_body_to_single_buffer(r);
|
904
|
+
}
|
905
|
+
else {
|
906
|
+
ngx_log_error(NGX_LOG_ERR, (r)->connection->log, 0, "push module: unexpected publisher message request body buffer location. please report this to the push module developers.");
|
907
|
+
return NULL;
|
908
|
+
}
|
909
|
+
|
910
|
+
NGX_HTTP_PUSH_BROADCAST_CHECK(buf, NULL, r, "push module: can't find or allocate publisher request body buffer");
|
911
|
+
|
912
|
+
content_type_len = (r->headers_in.content_type!=NULL ? r->headers_in.content_type->value.len : 0);
|
913
|
+
|
914
|
+
ngx_shmtx_lock(&ngx_http_push_shpool->mutex);
|
915
|
+
|
916
|
+
//create a buffer copy in shared mem
|
917
|
+
msg = ngx_http_push_slab_alloc_locked(sizeof(*msg) + content_type_len, "message + content_type");
|
918
|
+
NGX_HTTP_PUSH_BROADCAST_CHECK_LOCKED(msg, NULL, r, "push module: unable to allocate message in shared memory", ngx_http_push_shpool);
|
919
|
+
previous_msg=ngx_http_push_get_latest_message_locked(channel); //need this for entity-tags generation
|
920
|
+
|
921
|
+
buf_copy = ngx_http_push_slab_alloc_locked(NGX_HTTP_BUF_ALLOC_SIZE(buf), "message buffer copy");
|
922
|
+
NGX_HTTP_PUSH_BROADCAST_CHECK_LOCKED(buf_copy, NULL, r, "push module: unable to allocate buffer in shared memory", ngx_http_push_shpool) //magic nullcheck
|
923
|
+
ngx_http_push_copy_preallocated_buffer(buf, buf_copy);
|
924
|
+
|
925
|
+
msg->buf=buf_copy;
|
926
|
+
|
927
|
+
//Stamp the new message with entity tags
|
928
|
+
msg->message_time=ngx_time(); //ESSENTIAL TODO: make sure this ends up producing GMT time
|
929
|
+
msg->message_tag=(previous_msg!=NULL && msg->message_time == previous_msg->message_time) ? (previous_msg->message_tag + 1) : 0;
|
930
|
+
|
931
|
+
//store the content-type
|
932
|
+
if(content_type_len>0) {
|
933
|
+
msg->content_type.len=r->headers_in.content_type->value.len;
|
934
|
+
msg->content_type.data=(u_char *) (msg+1); //we had reserved a contiguous chunk, myes?
|
935
|
+
ngx_memcpy(msg->content_type.data, r->headers_in.content_type->value.data, msg->content_type.len);
|
936
|
+
}
|
937
|
+
else {
|
938
|
+
msg->content_type.len=0;
|
939
|
+
msg->content_type.data=NULL;
|
940
|
+
}
|
941
|
+
|
942
|
+
//queue stuff ought to be NULL
|
943
|
+
msg->queue.prev=NULL;
|
944
|
+
msg->queue.next=NULL;
|
945
|
+
|
946
|
+
msg->refcount=0;
|
947
|
+
|
948
|
+
//set message expiration time
|
949
|
+
time_t message_timeout = cf->buffer_timeout;
|
950
|
+
msg->expires = (message_timeout==0 ? 0 : (ngx_time() + message_timeout));
|
951
|
+
|
952
|
+
msg->delete_oldest_received_min_messages = cf->delete_oldest_received_message ? (ngx_uint_t) cf->min_messages : NGX_MAX_UINT32_VALUE;
|
953
|
+
//NGX_MAX_UINT32_VALUE to disable, otherwise = min_message_buffer_size of the publisher location from whence the message came
|
954
|
+
|
955
|
+
ngx_shmtx_unlock(&ngx_http_push_shpool->mutex);
|
956
|
+
//ngx_log_error(NGX_LOG_WARN, ngx_cycle->log, 0, CREATED_DBG, msg, msg->refcount, msg->queue.prev, msg->queue.next);
|
957
|
+
return msg;
|
958
|
+
}
|
959
|
+
|
960
|
+
static ngx_int_t ngx_http_push_store_enqueue_message(ngx_http_push_channel_t *channel, ngx_http_push_msg_t *msg, ngx_http_push_loc_conf_t *cf) {
|
961
|
+
ngx_shmtx_lock(&ngx_http_push_shpool->mutex);
|
962
|
+
ngx_queue_insert_tail(&channel->message_queue->queue, &msg->queue);
|
963
|
+
channel->messages++;
|
964
|
+
|
965
|
+
//now see if the queue is too big
|
966
|
+
if(channel->messages > (ngx_uint_t) cf->max_messages) {
|
967
|
+
//exceeeds max queue size. don't force it, someone might still be using this message.
|
968
|
+
ngx_http_push_delete_message_locked(channel, ngx_http_push_get_oldest_message_locked(channel), 0);
|
969
|
+
}
|
970
|
+
if(channel->messages > (ngx_uint_t) cf->min_messages) {
|
971
|
+
//exceeeds min queue size. maybe delete the oldest message
|
972
|
+
//no, don't do anything for now. This feature is badly implemented and I think I'll deprecate it.
|
973
|
+
}
|
974
|
+
|
975
|
+
ngx_shmtx_unlock(&ngx_http_push_shpool->mutex);
|
976
|
+
//ngx_log_error(NGX_LOG_WARN, ngx_cycle->log, 0, ENQUEUED_DBG, msg, msg->refcount, msg->queue.prev, msg->queue.next);
|
977
|
+
return NGX_OK;
|
978
|
+
}
|
979
|
+
|
980
|
+
static ngx_int_t default_publish_callback(ngx_int_t status, ngx_http_push_channel_t *ch, ngx_http_request_t *r) {
|
981
|
+
return status;
|
982
|
+
}
|
983
|
+
|
984
|
+
static ngx_int_t ngx_http_push_store_publish_message(ngx_str_t *channel_id, ngx_http_request_t *r, ngx_int_t (*callback)(ngx_int_t status, ngx_http_push_channel_t *ch, ngx_http_request_t *r)) {
|
985
|
+
ngx_http_push_channel_t *channel;
|
986
|
+
ngx_http_push_msg_t *msg;
|
987
|
+
ngx_http_push_loc_conf_t *cf = ngx_http_get_module_loc_conf(r, ngx_http_push_module);
|
988
|
+
ngx_int_t result=0;
|
989
|
+
if(callback==NULL) {
|
990
|
+
callback=&default_publish_callback;
|
991
|
+
}
|
992
|
+
if((channel=ngx_http_push_store_get_channel(channel_id, cf->channel_timeout, NULL))==NULL) { //always returns a channel, unless no memory left
|
993
|
+
return callback(NGX_ERROR, NULL, r);
|
994
|
+
//ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
995
|
+
}
|
996
|
+
|
997
|
+
if((msg = ngx_http_push_store_create_message(channel, r))==NULL) {
|
998
|
+
return callback(NGX_ERROR, channel, r);
|
999
|
+
//ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
1000
|
+
}
|
1001
|
+
|
1002
|
+
if(cf->max_messages > 0) { //channel buffers exist
|
1003
|
+
ngx_http_push_store_enqueue_message(channel, msg, cf);
|
1004
|
+
}
|
1005
|
+
else if(cf->max_messages == 0) {
|
1006
|
+
ngx_http_push_store_reserve_message(NULL, msg);
|
1007
|
+
}
|
1008
|
+
result= ngx_http_push_store_publish_raw(channel, msg, 0, NULL);
|
1009
|
+
return callback(result, channel, r);
|
1010
|
+
}
|
1011
|
+
|
1012
|
+
static ngx_int_t ngx_http_push_store_send_worker_message(ngx_http_push_channel_t *channel, ngx_http_push_subscriber_t *subscriber_sentinel, ngx_pid_t pid, ngx_int_t worker_slot, ngx_http_push_msg_t *msg, ngx_int_t status_code) {
|
1013
|
+
ngx_http_push_worker_msg_sentinel_t *worker_messages = ((ngx_http_push_shm_data_t *)ngx_http_push_shm_zone->data)->ipc;
|
1014
|
+
ngx_http_push_worker_msg_sentinel_t *sentinel = &worker_messages[worker_slot];
|
1015
|
+
ngx_http_push_worker_msg_t *newmessage;
|
1016
|
+
if((newmessage=ngx_http_push_slab_alloc(sizeof(*newmessage), "IPC worker message"))==NULL) {
|
1017
|
+
ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0, "push module: unable to allocate worker message");
|
1018
|
+
return NGX_ERROR;
|
1019
|
+
}
|
1020
|
+
newmessage->msg = msg;
|
1021
|
+
newmessage->status_code = status_code;
|
1022
|
+
newmessage->pid = pid;
|
1023
|
+
newmessage->subscriber_sentinel = subscriber_sentinel;
|
1024
|
+
newmessage->channel = channel;
|
1025
|
+
|
1026
|
+
ngx_http_push_store_lock_shmem();
|
1027
|
+
ngx_queue_insert_tail(&sentinel->queue, &newmessage->queue);
|
1028
|
+
ngx_http_push_store_unlock_shmem();
|
1029
|
+
return NGX_OK;
|
1030
|
+
|
1031
|
+
}
|
1032
|
+
|
1033
|
+
static void ngx_http_push_store_receive_worker_message(void) {
|
1034
|
+
ngx_http_push_worker_msg_t *prev_worker_msg, *worker_msg;
|
1035
|
+
ngx_http_push_worker_msg_sentinel_t *sentinel;
|
1036
|
+
const ngx_str_t *status_line = NULL;
|
1037
|
+
ngx_http_push_channel_t *channel;
|
1038
|
+
ngx_http_push_subscriber_t *subscriber_sentinel;
|
1039
|
+
ngx_int_t worker_msg_pid;
|
1040
|
+
|
1041
|
+
ngx_int_t status_code;
|
1042
|
+
ngx_http_push_msg_t *msg;
|
1043
|
+
|
1044
|
+
sentinel = &(((ngx_http_push_shm_data_t *)ngx_http_push_shm_zone->data)->ipc)[ngx_process_slot];
|
1045
|
+
|
1046
|
+
ngx_http_push_store_lock_shmem();
|
1047
|
+
worker_msg = (ngx_http_push_worker_msg_t *)ngx_queue_next(&sentinel->queue);
|
1048
|
+
ngx_http_push_store_unlock_shmem();
|
1049
|
+
while((void *)worker_msg != (void *)sentinel) {
|
1050
|
+
|
1051
|
+
ngx_http_push_store_lock_shmem();
|
1052
|
+
worker_msg_pid = worker_msg->pid;
|
1053
|
+
ngx_http_push_store_unlock_shmem();
|
1054
|
+
|
1055
|
+
if(worker_msg_pid == ngx_pid) {
|
1056
|
+
//ngx_log_error(NGX_LOG_WARN, ngx_cycle->log, 0, "process_worker_message processing proper worker_msg ");
|
1057
|
+
//everything is okay.
|
1058
|
+
|
1059
|
+
ngx_http_push_store_lock_shmem();
|
1060
|
+
status_code = worker_msg->status_code;
|
1061
|
+
msg = worker_msg->msg;
|
1062
|
+
channel = worker_msg->channel;
|
1063
|
+
subscriber_sentinel = worker_msg->subscriber_sentinel;
|
1064
|
+
ngx_http_push_store_unlock_shmem();
|
1065
|
+
|
1066
|
+
if(msg==NULL) {
|
1067
|
+
//just a status line, is all
|
1068
|
+
//status code only.
|
1069
|
+
switch(status_code) {
|
1070
|
+
case NGX_HTTP_CONFLICT:
|
1071
|
+
status_line=&NGX_HTTP_PUSH_HTTP_STATUS_409;
|
1072
|
+
break;
|
1073
|
+
|
1074
|
+
case NGX_HTTP_GONE:
|
1075
|
+
status_line=&NGX_HTTP_PUSH_HTTP_STATUS_410;
|
1076
|
+
break;
|
1077
|
+
|
1078
|
+
case 0:
|
1079
|
+
ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0, "push module: worker message contains neither a channel message nor a status code");
|
1080
|
+
//let's let the subscribers know that something went wrong and they might've missed a message
|
1081
|
+
status_code = NGX_HTTP_INTERNAL_SERVER_ERROR;
|
1082
|
+
//intentional fall-through
|
1083
|
+
default:
|
1084
|
+
status_line=NULL;
|
1085
|
+
}
|
1086
|
+
}
|
1087
|
+
|
1088
|
+
ngx_http_push_respond_to_subscribers(channel, subscriber_sentinel, msg, status_code, status_line);
|
1089
|
+
}
|
1090
|
+
else {
|
1091
|
+
//that's quite bad you see. a previous worker died with an undelivered message.
|
1092
|
+
//but all its subscribers' connections presumably got canned, too. so it's not so bad after all.
|
1093
|
+
//ngx_log_error(NGX_LOG_WARN, ngx_cycle->log, 0, "process_worker_message processing INVALID worker_msg ");
|
1094
|
+
|
1095
|
+
ngx_http_push_store_lock_shmem();
|
1096
|
+
|
1097
|
+
ngx_http_push_pid_queue_t *channel_worker_sentinel = worker_msg->channel->workers_with_subscribers;
|
1098
|
+
|
1099
|
+
ngx_http_push_pid_queue_t *channel_worker_cur = channel_worker_sentinel;
|
1100
|
+
ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0, "push module: worker %i intercepted a message intended for another worker process (%i) that probably died", ngx_pid, worker_msg->pid);
|
1101
|
+
|
1102
|
+
//delete that invalid sucker.
|
1103
|
+
while((channel_worker_cur=(ngx_http_push_pid_queue_t *)ngx_queue_next(&channel_worker_cur->queue))!=channel_worker_sentinel) {
|
1104
|
+
if(channel_worker_cur->pid == worker_msg->pid) {
|
1105
|
+
ngx_queue_remove(&channel_worker_cur->queue);
|
1106
|
+
ngx_http_push_slab_free_locked(channel_worker_cur);
|
1107
|
+
break;
|
1108
|
+
}
|
1109
|
+
}
|
1110
|
+
|
1111
|
+
ngx_http_push_store_unlock_shmem();
|
1112
|
+
|
1113
|
+
}
|
1114
|
+
//It may be worth it to memzero worker_msg for debugging purposes.
|
1115
|
+
prev_worker_msg = worker_msg;
|
1116
|
+
|
1117
|
+
ngx_http_push_store_lock_shmem();
|
1118
|
+
worker_msg = (ngx_http_push_worker_msg_t *)ngx_queue_next(&worker_msg->queue);
|
1119
|
+
ngx_http_push_slab_free_locked(prev_worker_msg);
|
1120
|
+
ngx_http_push_store_unlock_shmem();
|
1121
|
+
|
1122
|
+
}
|
1123
|
+
ngx_http_push_store_lock_shmem();
|
1124
|
+
ngx_queue_init(&sentinel->queue); //reset the worker message sentinel
|
1125
|
+
ngx_http_push_store_unlock_shmem();
|
1126
|
+
//ngx_log_error(NGX_LOG_WARN, ngx_cycle->log, 0, "process_worker_message finished");
|
1127
|
+
return;
|
1128
|
+
}
|
1129
|
+
|
1130
|
+
ngx_http_push_store_t ngx_http_push_store_memory = {
|
1131
|
+
//init
|
1132
|
+
&ngx_http_push_store_init_module,
|
1133
|
+
&ngx_http_push_store_init_worker,
|
1134
|
+
&ngx_http_push_store_init_postconfig,
|
1135
|
+
&ngx_http_push_store_create_main_conf,
|
1136
|
+
|
1137
|
+
//shutdown
|
1138
|
+
&ngx_http_push_store_exit_worker,
|
1139
|
+
&ngx_http_push_store_exit_master,
|
1140
|
+
|
1141
|
+
//async-friendly functions with callbacks
|
1142
|
+
&ngx_http_push_store_get_message, //+callback
|
1143
|
+
&ngx_http_push_store_subscribe, //+callback
|
1144
|
+
&ngx_http_push_store_publish_message, //+callback
|
1145
|
+
|
1146
|
+
//channel stuff,
|
1147
|
+
&ngx_http_push_store_get_channel, //creates channel if not found, +callback
|
1148
|
+
&ngx_http_push_store_find_channel, //returns channel or NULL if not found, +callback
|
1149
|
+
&ngx_http_push_store_delete_channel,
|
1150
|
+
|
1151
|
+
&ngx_http_push_store_get_channel_message,
|
1152
|
+
&ngx_http_push_store_reserve_message,
|
1153
|
+
&ngx_http_push_store_release_message,
|
1154
|
+
|
1155
|
+
//channel properties
|
1156
|
+
&ngx_http_push_store_channel_subscribers,
|
1157
|
+
&ngx_http_push_store_channel_worker_subscribers,
|
1158
|
+
&ngx_http_push_store_channel_next_subscriber,
|
1159
|
+
&ngx_http_push_store_channel_release_subscriber_sentinel,
|
1160
|
+
|
1161
|
+
//legacy shared-memory store helpers
|
1162
|
+
&ngx_http_push_store_lock_shmem,
|
1163
|
+
&ngx_http_push_store_unlock_shmem,
|
1164
|
+
&ngx_http_push_slab_alloc_locked,
|
1165
|
+
&ngx_http_push_slab_free_locked,
|
1166
|
+
|
1167
|
+
//message stuff
|
1168
|
+
&ngx_http_push_store_create_message,
|
1169
|
+
&ngx_http_push_delete_message,
|
1170
|
+
&ngx_http_push_delete_message_locked,
|
1171
|
+
&ngx_http_push_store_enqueue_message,
|
1172
|
+
&ngx_http_push_store_etag_from_message,
|
1173
|
+
&ngx_http_push_store_content_type_from_message,
|
1174
|
+
|
1175
|
+
//interprocess communication
|
1176
|
+
&ngx_http_push_store_send_worker_message,
|
1177
|
+
&ngx_http_push_store_receive_worker_message
|
1178
|
+
|
1179
|
+
|
1180
|
+
};
|