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.

Files changed (579) hide show
  1. checksums.yaml +8 -8
  2. checksums.yaml.gz.asc +7 -7
  3. data.tar.gz.asc +7 -7
  4. data/CHANGELOG +15 -0
  5. data/bin/passenger-install-apache2-module +2 -1
  6. data/bin/passenger-install-nginx-module +8 -2
  7. data/ext/apache2/Hooks.cpp +21 -2
  8. data/ext/apache2/MergeDirConfig.cpp +40 -40
  9. data/ext/common/ApplicationPool2/Group.h +14 -10
  10. data/ext/common/ApplicationPool2/Implementation.cpp +13 -7
  11. data/ext/common/ApplicationPool2/SmartSpawner.h +4 -1
  12. data/ext/common/Constants.h +1 -1
  13. data/ext/nginx/ContentHandler.c +17 -1
  14. data/lib/phusion_passenger.rb +4 -5
  15. data/lib/phusion_passenger/platform_info/depcheck_specs/libs.rb +4 -3
  16. data/lib/phusion_passenger/platform_info/openssl.rb +61 -0
  17. data/lib/phusion_passenger/standalone/runtime_installer.rb +27 -22
  18. data/packaging/debian/LICENSE.md +19 -0
  19. data/packaging/debian/README.md +320 -0
  20. data/packaging/debian/Vagrantfile +25 -0
  21. data/packaging/debian/build +210 -0
  22. data/packaging/debian/debian_specs/nginx/changelog +1989 -0
  23. data/packaging/debian/debian_specs/nginx/compat.erb +5 -0
  24. data/packaging/debian/debian_specs/nginx/conf/fastcgi.conf +25 -0
  25. data/packaging/debian/debian_specs/nginx/conf/fastcgi_params +24 -0
  26. data/packaging/debian/debian_specs/nginx/conf/koi-utf +109 -0
  27. data/packaging/debian/debian_specs/nginx/conf/koi-win +103 -0
  28. data/packaging/debian/debian_specs/nginx/conf/mime.types +89 -0
  29. data/packaging/debian/debian_specs/nginx/conf/nginx.conf.erb +97 -0
  30. data/packaging/debian/debian_specs/nginx/conf/proxy_params +4 -0
  31. data/packaging/debian/debian_specs/nginx/conf/scgi_params +16 -0
  32. data/packaging/debian/debian_specs/nginx/conf/sites-available/default.erb +93 -0
  33. data/packaging/debian/debian_specs/nginx/conf/snippets/fastcgi-php.conf +13 -0
  34. data/packaging/debian/debian_specs/nginx/conf/snippets/snakeoil.conf +5 -0
  35. data/packaging/debian/debian_specs/nginx/conf/uwsgi_params +16 -0
  36. data/packaging/debian/debian_specs/nginx/conf/win-utf +125 -0
  37. data/packaging/debian/debian_specs/nginx/control.erb +226 -0
  38. data/packaging/debian/debian_specs/nginx/copyright +196 -0
  39. data/packaging/debian/debian_specs/nginx/debian-full.lintian-overrides +1 -0
  40. data/packaging/debian/debian_specs/nginx/gbp.conf +2 -0
  41. data/packaging/debian/debian_specs/nginx/help/docs/fcgiwrap +14 -0
  42. data/packaging/debian/debian_specs/nginx/help/docs/php +119 -0
  43. data/packaging/debian/debian_specs/nginx/help/docs/support-irc +28 -0
  44. data/packaging/debian/debian_specs/nginx/help/docs/upstream +51 -0
  45. data/packaging/debian/debian_specs/nginx/help/examples/drupal +114 -0
  46. data/packaging/debian/debian_specs/nginx/help/examples/http +59 -0
  47. data/packaging/debian/debian_specs/nginx/help/examples/mail +30 -0
  48. data/packaging/debian/debian_specs/nginx/help/examples/mailman +59 -0
  49. data/packaging/debian/debian_specs/nginx/help/examples/nginx.conf +34 -0
  50. data/packaging/debian/debian_specs/nginx/help/examples/nginx_modsite +162 -0
  51. data/packaging/debian/debian_specs/nginx/help/examples/virtual_hosts +155 -0
  52. data/packaging/debian/debian_specs/nginx/help/examples/wordpress +74 -0
  53. data/packaging/debian/debian_specs/nginx/helpers.rb +41 -0
  54. data/packaging/debian/debian_specs/nginx/index-debian.html.in +32 -0
  55. data/packaging/debian/debian_specs/nginx/index-ubuntu.html.in +32 -0
  56. data/packaging/debian/debian_specs/nginx/index.html.erb +10 -0
  57. data/packaging/debian/debian_specs/nginx/modules/README.Modules-versions +65 -0
  58. data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/README.markdown +510 -0
  59. data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/config +5 -0
  60. data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/doc/HttpHeadersMoreModule.wiki +395 -0
  61. data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ddebug.h +119 -0
  62. data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_filter_module.c +348 -0
  63. data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_filter_module.h +80 -0
  64. data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_headers_in.c +826 -0
  65. data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_headers_in.h +26 -0
  66. data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_headers_out.c +716 -0
  67. data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_headers_out.h +26 -0
  68. data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_util.c +380 -0
  69. data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_util.h +52 -0
  70. data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/util/build.sh +32 -0
  71. data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/valgrind.suppress +215 -0
  72. data/packaging/debian/debian_specs/nginx/modules/nginx-auth-pam/ChangeLog +35 -0
  73. data/packaging/debian/debian_specs/nginx/modules/nginx-auth-pam/LICENSE +25 -0
  74. data/packaging/debian/debian_specs/nginx/modules/nginx-auth-pam/README.md +93 -0
  75. data/packaging/debian/debian_specs/nginx/modules/nginx-auth-pam/config +4 -0
  76. data/packaging/debian/debian_specs/nginx/modules/nginx-auth-pam/ngx_http_auth_pam_module.c +462 -0
  77. data/packaging/debian/debian_specs/nginx/modules/nginx-cache-purge/CHANGES +66 -0
  78. data/packaging/debian/debian_specs/nginx/modules/nginx-cache-purge/LICENSE +26 -0
  79. data/packaging/debian/debian_specs/nginx/modules/nginx-cache-purge/README.md +171 -0
  80. data/packaging/debian/debian_specs/nginx/modules/nginx-cache-purge/TODO.md +7 -0
  81. data/packaging/debian/debian_specs/nginx/modules/nginx-cache-purge/config +21 -0
  82. data/packaging/debian/debian_specs/nginx/modules/nginx-cache-purge/ngx_cache_purge_module.c +1803 -0
  83. data/packaging/debian/debian_specs/nginx/modules/nginx-dav-ext-module/README +29 -0
  84. data/packaging/debian/debian_specs/nginx/modules/nginx-dav-ext-module/config +9 -0
  85. data/packaging/debian/debian_specs/nginx/modules/nginx-dav-ext-module/ngx_http_dav_ext_module.c +824 -0
  86. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/README +139 -0
  87. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/README_AUTO_LIB +395 -0
  88. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/TODO +1 -0
  89. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/actions/array +10 -0
  90. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/actions/palloc +8 -0
  91. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/build +597 -0
  92. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/action_replacements +5 -0
  93. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/action_types +12 -0
  94. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/conf_args +22 -0
  95. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/conf_locs +25 -0
  96. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/conf_macros +35 -0
  97. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/contexts +22 -0
  98. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/header_files +3 -0
  99. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/headers +4 -0
  100. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/module_dependencies +5 -0
  101. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/modules_optional +15 -0
  102. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/prefixes +2 -0
  103. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/src/array.h +7 -0
  104. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/src/conf_cmd_basic.h +43 -0
  105. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/src/conf_merge.h +78 -0
  106. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/src/palloc.h +6 -0
  107. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/text/autogen +12 -0
  108. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/config +49 -0
  109. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/docs/core/action_macros +63 -0
  110. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/docs/core/conf_cmds +62 -0
  111. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/docs/modules/set_var +124 -0
  112. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/docs/patches/more_logging_info +48 -0
  113. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/docs/upstream/list +45 -0
  114. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/examples/README +12 -0
  115. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/examples/http/set_var/config +4 -0
  116. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/examples/http/set_var/ngx_http_set_var_examples_module.c +136 -0
  117. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/ngx_auto_lib_core +797 -0
  118. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/notes/CHANGES +17 -0
  119. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/notes/LICENSE +24 -0
  120. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_array.h +113 -0
  121. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_conf_cmd_basic.h +2203 -0
  122. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_conf_cmd_extra.h +5423 -0
  123. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_conf_merge.h +227 -0
  124. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_config.c +72 -0
  125. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_config.h +98 -0
  126. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_includes.h +66 -0
  127. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_palloc.h +112 -0
  128. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/patches/auto_config +16 -0
  129. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/patches/expose_rewrite_functions +291 -0
  130. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/patches/rewrite_phase_handler +19 -0
  131. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/hash/md5.h +117 -0
  132. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/hash/murmurhash2.c +77 -0
  133. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/hash/sha.h +200 -0
  134. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk.c +155 -0
  135. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk.h +58 -0
  136. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_buf.c +43 -0
  137. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_buf.h +5 -0
  138. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_complex_path.c +129 -0
  139. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_complex_path.h +30 -0
  140. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_complex_value.c +192 -0
  141. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_complex_value.h +21 -0
  142. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_conf_file.c +396 -0
  143. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_conf_file.h +44 -0
  144. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_debug.c +72 -0
  145. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_debug.h +171 -0
  146. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_encoding.c +57 -0
  147. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_encoding.h +12 -0
  148. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_hash.c +82 -0
  149. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_hash.h +45 -0
  150. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_http.c +138 -0
  151. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_http.h +3 -0
  152. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_http_headers.h +35 -0
  153. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_log.c +3 -0
  154. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_log.h +165 -0
  155. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_parse.h +67 -0
  156. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_path.c +583 -0
  157. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_path.h +22 -0
  158. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_process.c +20 -0
  159. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_process.h +12 -0
  160. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_regex.c +215 -0
  161. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_regex.h +7 -0
  162. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_rewrite.c +103 -0
  163. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_rewrite.h +26 -0
  164. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_set_var.c +602 -0
  165. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_set_var.h +44 -0
  166. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_string.c +434 -0
  167. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_string.h +37 -0
  168. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_string_util.h +14 -0
  169. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_upstream_list.c +205 -0
  170. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_upstream_list.h +27 -0
  171. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_uri.c +45 -0
  172. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_uri.h +6 -0
  173. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/LICENSE +25 -0
  174. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/README.markdown +1850 -0
  175. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/config +5 -0
  176. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/doc/HttpEchoModule.wiki +1558 -0
  177. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ddebug.h +109 -0
  178. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_echo.c +344 -0
  179. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_echo.h +25 -0
  180. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_filter.c +282 -0
  181. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_filter.h +15 -0
  182. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_foreach.c +183 -0
  183. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_foreach.h +16 -0
  184. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_handler.c +429 -0
  185. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_handler.h +18 -0
  186. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_location.c +178 -0
  187. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_location.h +13 -0
  188. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_module.c +667 -0
  189. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_module.h +137 -0
  190. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_request_info.c +452 -0
  191. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_request_info.h +31 -0
  192. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_sleep.c +208 -0
  193. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_sleep.h +16 -0
  194. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_subrequest.c +788 -0
  195. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_subrequest.h +19 -0
  196. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_timer.c +96 -0
  197. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_timer.h +13 -0
  198. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_util.c +298 -0
  199. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_util.h +58 -0
  200. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_var.c +110 -0
  201. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_var.h +9 -0
  202. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/util/build.sh +45 -0
  203. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/util/releng +8 -0
  204. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/util/wiki2pod.pl +131 -0
  205. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/valgrind.suppress +38 -0
  206. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/LICENCE +24 -0
  207. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/README +206 -0
  208. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/changelog.txt +54 -0
  209. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/config +26 -0
  210. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/protocol.txt +191 -0
  211. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/ngx_http_push_defs.c +59 -0
  212. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/ngx_http_push_defs.h +73 -0
  213. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/ngx_http_push_module.c +783 -0
  214. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/ngx_http_push_module.h +31 -0
  215. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/ngx_http_push_module_setup.c +361 -0
  216. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/ngx_http_push_types.h +120 -0
  217. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/memory/store.c +1180 -0
  218. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/memory/store.h +1 -0
  219. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/ngx_http_push_module_ipc.c +146 -0
  220. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/ngx_http_push_module_ipc.h +5 -0
  221. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/ngx_http_push_store.h +51 -0
  222. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/ngx_rwlock.c +178 -0
  223. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/ngx_rwlock.h +5 -0
  224. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/rbtree_util.c +246 -0
  225. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/rbtree_util.h +9 -0
  226. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/Changes +51 -0
  227. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/README.markdown +6954 -0
  228. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/config +363 -0
  229. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/doc/HttpLuaModule.wiki +5898 -0
  230. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/dtrace/ngx_lua_provider.d +61 -0
  231. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/misc/recv-until-pm/Makefile +3 -0
  232. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/misc/recv-until-pm/lib/RecvUntil.pm +138 -0
  233. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/misc/recv-until-pm/t/sanity.t +140 -0
  234. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/api/ngx_http_lua_api.h +52 -0
  235. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ddebug.h +82 -0
  236. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_accessby.c +377 -0
  237. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_accessby.h +22 -0
  238. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_api.c +77 -0
  239. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_args.c +537 -0
  240. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_args.h +20 -0
  241. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_bodyfilterby.c +632 -0
  242. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_bodyfilterby.h +31 -0
  243. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_cache.c +296 -0
  244. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_cache.h +24 -0
  245. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_capturefilter.c +175 -0
  246. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_capturefilter.h +20 -0
  247. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_clfactory.c +887 -0
  248. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_clfactory.h +22 -0
  249. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_common.h +478 -0
  250. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_config.c +67 -0
  251. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_config.h +19 -0
  252. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_consts.c +148 -0
  253. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_consts.h +20 -0
  254. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_contentby.c +369 -0
  255. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_contentby.h +26 -0
  256. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_control.c +483 -0
  257. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_control.h +20 -0
  258. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_coroutine.c +379 -0
  259. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_coroutine.h +23 -0
  260. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_ctx.c +216 -0
  261. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_ctx.h +23 -0
  262. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_directive.c +1081 -0
  263. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_directive.h +56 -0
  264. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_exception.c +58 -0
  265. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_exception.h +33 -0
  266. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headerfilterby.c +302 -0
  267. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headerfilterby.h +29 -0
  268. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headers.c +1370 -0
  269. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headers.h +22 -0
  270. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headers_in.c +782 -0
  271. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headers_in.h +22 -0
  272. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headers_out.c +625 -0
  273. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headers_out.h +23 -0
  274. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_initby.c +42 -0
  275. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_initby.h +23 -0
  276. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_initworkerby.c +320 -0
  277. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_initworkerby.h +25 -0
  278. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_log.c +300 -0
  279. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_log.h +20 -0
  280. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_logby.c +227 -0
  281. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_logby.h +22 -0
  282. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_misc.c +252 -0
  283. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_misc.h +20 -0
  284. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_module.c +924 -0
  285. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_ndk.c +184 -0
  286. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_ndk.h +21 -0
  287. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_output.c +794 -0
  288. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_output.h +28 -0
  289. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_pcrefix.c +106 -0
  290. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_pcrefix.h +23 -0
  291. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_phase.c +94 -0
  292. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_phase.h +13 -0
  293. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_probe.h +85 -0
  294. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_regex.c +2468 -0
  295. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_regex.h +22 -0
  296. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_req_body.c +1169 -0
  297. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_req_body.h +20 -0
  298. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_req_method.c +252 -0
  299. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_req_method.h +19 -0
  300. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_rewriteby.c +351 -0
  301. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_rewriteby.h +22 -0
  302. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_script.c +538 -0
  303. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_script.h +86 -0
  304. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_setby.c +216 -0
  305. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_setby.h +15 -0
  306. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_shdict.c +1844 -0
  307. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_shdict.h +52 -0
  308. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_sleep.c +191 -0
  309. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_sleep.h +20 -0
  310. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_socket_tcp.c +5314 -0
  311. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_socket_tcp.h +156 -0
  312. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_socket_udp.c +1624 -0
  313. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_socket_udp.h +56 -0
  314. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_string.c +704 -0
  315. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_string.h +20 -0
  316. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_subrequest.c +1741 -0
  317. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_subrequest.h +46 -0
  318. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_time.c +278 -0
  319. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_time.h +21 -0
  320. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_timer.c +661 -0
  321. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_timer.h +20 -0
  322. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_uri.c +110 -0
  323. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_uri.h +20 -0
  324. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_uthread.c +283 -0
  325. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_uthread.h +36 -0
  326. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_util.c +3972 -0
  327. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_util.h +423 -0
  328. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_variable.c +499 -0
  329. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_variable.h +20 -0
  330. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_worker.c +64 -0
  331. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_worker.h +17 -0
  332. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/tapset/ngx_lua.stp +5 -0
  333. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/build.sh +39 -0
  334. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/build2.sh +55 -0
  335. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/fix-comments +27 -0
  336. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/gdbinit +415 -0
  337. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/ngx-links +62 -0
  338. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/reindex +64 -0
  339. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/releng +8 -0
  340. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/retab +8 -0
  341. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/revim +102 -0
  342. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/run_test.sh +10 -0
  343. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/update-readme.sh +4 -0
  344. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/valgrind.suppress +144 -0
  345. data/packaging/debian/debian_specs/nginx/modules/nginx-upload-progress/CHANGES +107 -0
  346. data/packaging/debian/debian_specs/nginx/modules/nginx-upload-progress/LICENSE +25 -0
  347. data/packaging/debian/debian_specs/nginx/modules/nginx-upload-progress/Makefile +8 -0
  348. data/packaging/debian/debian_specs/nginx/modules/nginx-upload-progress/README +329 -0
  349. data/packaging/debian/debian_specs/nginx/modules/nginx-upload-progress/config +3 -0
  350. data/packaging/debian/debian_specs/nginx/modules/nginx-upload-progress/ngx_http_uploadprogress_module.c +1774 -0
  351. data/packaging/debian/debian_specs/nginx/modules/nginx-upstream-fair/README +53 -0
  352. data/packaging/debian/debian_specs/nginx/modules/nginx-upstream-fair/config +3 -0
  353. data/packaging/debian/debian_specs/nginx/modules/nginx-upstream-fair/ngx_http_upstream_fair_module.c +1356 -0
  354. data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/CHANGELOG.md +37 -0
  355. data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/HACKING.md +24 -0
  356. data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/LICENSE +20 -0
  357. data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/README.rst +182 -0
  358. data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/config +8 -0
  359. data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/nginx-0.6-support.patch +23 -0
  360. data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/ngx_http_fancyindex_module.c +1305 -0
  361. data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/template.awk +52 -0
  362. data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/template.h +103 -0
  363. data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/template.html +102 -0
  364. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/CHANGES +37 -0
  365. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/README +141 -0
  366. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/config +3 -0
  367. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/doc/README.google_code_home_page.wiki +120 -0
  368. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/doc/README.html +199 -0
  369. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/doc/README.wiki +123 -0
  370. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/ngx_http_subs_filter_module.c +1298 -0
  371. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/README +275 -0
  372. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/AutoInstall.pm +820 -0
  373. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install.pm +470 -0
  374. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/AutoInstall.pm +82 -0
  375. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/Base.pm +83 -0
  376. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/Can.pm +81 -0
  377. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/Fetch.pm +93 -0
  378. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/Include.pm +34 -0
  379. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/Makefile.pm +415 -0
  380. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/Metadata.pm +716 -0
  381. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/TestBase.pm +29 -0
  382. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/Win32.pm +64 -0
  383. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/WriteAll.pm +63 -0
  384. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Spiffy.pm +539 -0
  385. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Test/Base.pm +682 -0
  386. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Test/Base/Filter.pm +341 -0
  387. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Test/Builder.pm +1413 -0
  388. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Test/Builder/Module.pm +81 -0
  389. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Test/More.pm +735 -0
  390. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/lib/Test/Nginx.pm +315 -0
  391. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/lib/Test/Nginx/LWP.pm +524 -0
  392. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/lib/Test/Nginx/Socket.pm +1749 -0
  393. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/lib/Test/Nginx/Util.pm +874 -0
  394. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/t/subs.t +136 -0
  395. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/t/subs_capture.t +32 -0
  396. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/t/subs_fix_string.t +32 -0
  397. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/t/subs_regex.t +108 -0
  398. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/t/subs_types.t +59 -0
  399. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/test.sh +5 -0
  400. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/util/update-readme.sh +7 -0
  401. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/util/wiki2google_code_homepage.pl +29 -0
  402. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/util/wiki2pod.pl +129 -0
  403. data/packaging/debian/debian_specs/nginx/nginx-common.NEWS +135 -0
  404. data/packaging/debian/debian_specs/nginx/nginx-common.README.Debian +45 -0
  405. data/packaging/debian/debian_specs/nginx/nginx-common.dirs.erb +32 -0
  406. data/packaging/debian/debian_specs/nginx/nginx-common.install +3 -0
  407. data/packaging/debian/debian_specs/nginx/nginx-common.lintian-overrides +2 -0
  408. data/packaging/debian/debian_specs/nginx/nginx-common.manpages +1 -0
  409. data/packaging/debian/debian_specs/nginx/nginx-common.nginx.default +10 -0
  410. data/packaging/debian/debian_specs/nginx/nginx-common.nginx.init.erb +214 -0
  411. data/packaging/debian/debian_specs/nginx/nginx-common.nginx.logrotate +18 -0
  412. data/packaging/debian/debian_specs/nginx/nginx-common.nginx.service.erb +37 -0
  413. data/packaging/debian/debian_specs/nginx/nginx-common.postinst.erb +66 -0
  414. data/packaging/debian/debian_specs/nginx/nginx-common.postrm.erb +46 -0
  415. data/packaging/debian/debian_specs/nginx/nginx-common.preinst +47 -0
  416. data/packaging/debian/debian_specs/nginx/nginx-common.prerm.erb +28 -0
  417. data/packaging/debian/debian_specs/nginx/nginx-doc.docs +2 -0
  418. data/packaging/debian/debian_specs/nginx/nginx-doc.examples +1 -0
  419. data/packaging/debian/debian_specs/nginx/nginx-extras.install.erb +17 -0
  420. data/packaging/debian/debian_specs/nginx/nginx-extras.lintian-overrides +1 -0
  421. data/packaging/debian/debian_specs/nginx/nginx-extras.postinst.erb +44 -0
  422. data/packaging/debian/debian_specs/nginx/nginx-extras.prerm +22 -0
  423. data/packaging/debian/debian_specs/nginx/nginx.1 +47 -0
  424. data/packaging/debian/debian_specs/nginx/patches/perl-use-dpkg-buildflags.patch +23 -0
  425. data/packaging/debian/debian_specs/nginx/patches/series +1 -0
  426. data/packaging/debian/debian_specs/nginx/rules.erb +185 -0
  427. data/packaging/debian/debian_specs/nginx/source/format +1 -0
  428. data/packaging/debian/debian_specs/nginx/tests/control +4 -0
  429. data/packaging/debian/debian_specs/nginx/ufw/nginx +14 -0
  430. data/packaging/debian/debian_specs/nginx/upstream/signing-key.asc +34 -0
  431. data/packaging/debian/debian_specs/nginx/watch +3 -0
  432. data/packaging/debian/debian_specs/passenger/README.Debian +12 -0
  433. data/packaging/debian/debian_specs/passenger/changelog +316 -0
  434. data/packaging/debian/debian_specs/passenger/compat +1 -0
  435. data/packaging/debian/debian_specs/passenger/control.erb +123 -0
  436. data/packaging/debian/debian_specs/passenger/copyright +385 -0
  437. data/packaging/debian/debian_specs/passenger/helpers.rb +24 -0
  438. data/packaging/debian/debian_specs/passenger/libapache2-mod-passenger.install +3 -0
  439. data/packaging/debian/debian_specs/passenger/libapache2-mod-passenger.postinst +36 -0
  440. data/packaging/debian/debian_specs/passenger/libapache2-mod-passenger.prerm +15 -0
  441. data/packaging/debian/debian_specs/passenger/locations.ini.erb +14 -0
  442. data/packaging/debian/debian_specs/passenger/passenger-dev.install.erb +3 -0
  443. data/packaging/debian/debian_specs/passenger/passenger-doc.install.erb +2 -0
  444. data/packaging/debian/debian_specs/passenger/passenger.conf +6 -0
  445. data/packaging/debian/debian_specs/passenger/passenger.docs +4 -0
  446. data/packaging/debian/debian_specs/passenger/passenger.install.erb +16 -0
  447. data/packaging/debian/debian_specs/passenger/passenger.load +3 -0
  448. data/packaging/debian/debian_specs/passenger/passenger.manpages +3 -0
  449. data/packaging/debian/debian_specs/passenger/passenger_free_ruby.c +29 -0
  450. data/packaging/debian/debian_specs/passenger/passenger_ruby_utils.c +54 -0
  451. data/packaging/debian/debian_specs/passenger/passenger_system_ruby.c.erb +37 -0
  452. data/packaging/debian/debian_specs/passenger/patches/series +0 -0
  453. data/packaging/debian/debian_specs/passenger/rules.erb +84 -0
  454. data/packaging/debian/debian_specs/passenger/source/format +1 -0
  455. data/packaging/debian/debian_specs/passenger_enterprise/README.Debian +12 -0
  456. data/packaging/debian/debian_specs/passenger_enterprise/changelog +316 -0
  457. data/packaging/debian/debian_specs/passenger_enterprise/compat +1 -0
  458. data/packaging/debian/debian_specs/passenger_enterprise/control.erb +123 -0
  459. data/packaging/debian/debian_specs/passenger_enterprise/copyright +385 -0
  460. data/packaging/debian/debian_specs/passenger_enterprise/helpers.rb +2 -0
  461. data/packaging/debian/debian_specs/passenger_enterprise/libapache2-mod-passenger-enterprise.install +3 -0
  462. data/packaging/debian/debian_specs/passenger_enterprise/libapache2-mod-passenger-enterprise.postinst +36 -0
  463. data/packaging/debian/debian_specs/passenger_enterprise/libapache2-mod-passenger-enterprise.prerm +15 -0
  464. data/packaging/debian/debian_specs/passenger_enterprise/locations.ini.erb +14 -0
  465. data/packaging/debian/debian_specs/passenger_enterprise/passenger-enterprise-dev.install.erb +3 -0
  466. data/packaging/debian/debian_specs/passenger_enterprise/passenger-enterprise-doc.install.erb +2 -0
  467. data/packaging/debian/debian_specs/passenger_enterprise/passenger-enterprise.docs +4 -0
  468. data/packaging/debian/debian_specs/passenger_enterprise/passenger-enterprise.install.erb +14 -0
  469. data/packaging/debian/debian_specs/passenger_enterprise/passenger-enterprise.manpages +3 -0
  470. data/packaging/debian/debian_specs/passenger_enterprise/passenger.conf +6 -0
  471. data/packaging/debian/debian_specs/passenger_enterprise/passenger.load +3 -0
  472. data/packaging/debian/debian_specs/passenger_enterprise/passenger_free_ruby.c.erb +1 -0
  473. data/packaging/debian/debian_specs/passenger_enterprise/passenger_ruby_utils.c.erb +1 -0
  474. data/packaging/debian/debian_specs/passenger_enterprise/passenger_system_ruby.c.erb +1 -0
  475. data/packaging/debian/debian_specs/passenger_enterprise/patches/series +0 -0
  476. data/packaging/debian/debian_specs/passenger_enterprise/rules.erb +84 -0
  477. data/packaging/debian/debian_specs/passenger_enterprise/source/format +1 -0
  478. data/packaging/debian/docker_images/Makefile +38 -0
  479. data/packaging/debian/docker_images/buildbox/CONTAINER_VERSION.txt +0 -0
  480. data/packaging/debian/docker_images/buildbox/Dockerfile +3 -0
  481. data/packaging/debian/docker_images/buildbox/Gemfile +9 -0
  482. data/packaging/debian/docker_images/buildbox/Gemfile.lock +42 -0
  483. data/packaging/debian/docker_images/buildbox/install.sh +85 -0
  484. data/packaging/debian/docker_images/buildbox/pbuilderrc +4 -0
  485. data/packaging/debian/docker_images/buildbox/sudoers.conf +6 -0
  486. data/packaging/debian/docker_images/setup-buildbox-docker-image +7 -0
  487. data/packaging/debian/docker_images/setup-testbox-docker-image-debian-6 +7 -0
  488. data/packaging/debian/docker_images/setup-testbox-docker-image-debian-7 +7 -0
  489. data/packaging/debian/docker_images/setup-testbox-docker-image-debian-8 +7 -0
  490. data/packaging/debian/docker_images/setup-testbox-docker-image-ubuntu-12.04 +7 -0
  491. data/packaging/debian/docker_images/setup-testbox-docker-image-ubuntu-14.04 +7 -0
  492. data/packaging/debian/docker_images/setup-testbox-docker-image-ubuntu-15.04 +7 -0
  493. data/packaging/debian/docker_images/setup-testbox-docker-image-ubuntu-15.10 +7 -0
  494. data/packaging/debian/docker_images/testbox-debian-6/Dockerfile +3 -0
  495. data/packaging/debian/docker_images/testbox-debian-6/Gemfile +2 -0
  496. data/packaging/debian/docker_images/testbox-debian-6/Gemfile.lock +23 -0
  497. data/packaging/debian/docker_images/testbox-debian-6/argparse.py +2374 -0
  498. data/packaging/debian/docker_images/testbox-debian-6/install.sh +78 -0
  499. data/packaging/debian/docker_images/testbox-debian-7/Dockerfile +3 -0
  500. data/packaging/debian/docker_images/testbox-debian-7/Gemfile +2 -0
  501. data/packaging/debian/docker_images/testbox-debian-7/Gemfile.lock +23 -0
  502. data/packaging/debian/docker_images/testbox-debian-7/install.sh +71 -0
  503. data/packaging/debian/docker_images/testbox-debian-8/Dockerfile +3 -0
  504. data/packaging/debian/docker_images/testbox-debian-8/Gemfile +2 -0
  505. data/packaging/debian/docker_images/testbox-debian-8/Gemfile.lock +23 -0
  506. data/packaging/debian/docker_images/testbox-debian-8/install.sh +70 -0
  507. data/packaging/debian/docker_images/testbox-ubuntu-12.04/Dockerfile +3 -0
  508. data/packaging/debian/docker_images/testbox-ubuntu-12.04/Gemfile +2 -0
  509. data/packaging/debian/docker_images/testbox-ubuntu-12.04/Gemfile.lock +23 -0
  510. data/packaging/debian/docker_images/testbox-ubuntu-12.04/install.sh +69 -0
  511. data/packaging/debian/docker_images/testbox-ubuntu-14.04/Dockerfile +3 -0
  512. data/packaging/debian/docker_images/testbox-ubuntu-14.04/Gemfile +2 -0
  513. data/packaging/debian/docker_images/testbox-ubuntu-14.04/Gemfile.lock +23 -0
  514. data/packaging/debian/docker_images/testbox-ubuntu-14.04/install.sh +69 -0
  515. data/packaging/debian/docker_images/testbox-ubuntu-15.04/Dockerfile +3 -0
  516. data/packaging/debian/docker_images/testbox-ubuntu-15.04/Gemfile +2 -0
  517. data/packaging/debian/docker_images/testbox-ubuntu-15.04/Gemfile.lock +23 -0
  518. data/packaging/debian/docker_images/testbox-ubuntu-15.04/install.sh +69 -0
  519. data/packaging/debian/docker_images/testbox-ubuntu-15.10/Dockerfile +3 -0
  520. data/packaging/debian/docker_images/testbox-ubuntu-15.10/Gemfile +2 -0
  521. data/packaging/debian/docker_images/testbox-ubuntu-15.10/Gemfile.lock +23 -0
  522. data/packaging/debian/docker_images/testbox-ubuntu-15.10/install.sh +69 -0
  523. data/packaging/debian/internal/build/Rakefile +235 -0
  524. data/packaging/debian/internal/build/build-passenger-orig-tarball.sh +76 -0
  525. data/packaging/debian/internal/build/build-source-package.rb +121 -0
  526. data/packaging/debian/internal/build/download-nginx-orig-tarball.sh +17 -0
  527. data/packaging/debian/internal/build/rakefile_support.rb +96 -0
  528. data/packaging/debian/internal/build/setup-environment-essentials.sh +15 -0
  529. data/packaging/debian/internal/build/setup-environment.sh +29 -0
  530. data/packaging/debian/internal/lib/distro_info.rb +82 -0
  531. data/packaging/debian/internal/lib/distro_info.sh +303 -0
  532. data/packaging/debian/internal/lib/distro_info.sh.erb +65 -0
  533. data/packaging/debian/internal/lib/library.sh +83 -0
  534. data/packaging/debian/internal/lib/preprocessor.rb +173 -0
  535. data/packaging/debian/internal/lib/tracking.rb +95 -0
  536. data/packaging/debian/internal/lib/tracking_category.rb +45 -0
  537. data/packaging/debian/internal/lib/tracking_database.rb +132 -0
  538. data/packaging/debian/internal/lib/tracking_task.rb +148 -0
  539. data/packaging/debian/internal/lib/utils.rb +78 -0
  540. data/packaging/debian/internal/publish/Rakefile +97 -0
  541. data/packaging/debian/internal/publish/oss-binaries.phusionpassenger.com-fingerprint.txt +1 -0
  542. data/packaging/debian/internal/publish/packagecloud_fingerprint.txt +1 -0
  543. data/packaging/debian/internal/publish/passenger_website_fingerprint.txt +1 -0
  544. data/packaging/debian/internal/publish/preinit.sh +7 -0
  545. data/packaging/debian/internal/publish/rakefile_support.rb +183 -0
  546. data/packaging/debian/internal/scripts/gpg_noninteractive/gpg +11 -0
  547. data/packaging/debian/internal/scripts/initccache.sh +35 -0
  548. data/packaging/debian/internal/scripts/inituidgid.sh +19 -0
  549. data/packaging/debian/internal/scripts/my_init +340 -0
  550. data/packaging/debian/internal/scripts/pin_certificates +34 -0
  551. data/packaging/debian/internal/scripts/regen_distro_info_script.sh +3 -0
  552. data/packaging/debian/internal/scripts/setup-vagrant.sh +12 -0
  553. data/packaging/debian/internal/scripts/setuser +31 -0
  554. data/packaging/debian/internal/shell/initpbuilder.sh +3 -0
  555. data/packaging/debian/internal/shell/preinit.sh +28 -0
  556. data/packaging/debian/internal/shell/sudoers.conf +1 -0
  557. data/packaging/debian/internal/test/apache/apache-24.conf +5 -0
  558. data/packaging/debian/internal/test/apache/apache-pre-24.conf +4 -0
  559. data/packaging/debian/internal/test/apache/vhost.conf +17 -0
  560. data/packaging/debian/internal/test/misc/config.json +15 -0
  561. data/packaging/debian/internal/test/misc/hosts.conf +4 -0
  562. data/packaging/debian/internal/test/misc/init.sh +25 -0
  563. data/packaging/debian/internal/test/misc/nodejs_test_app.js +6 -0
  564. data/packaging/debian/internal/test/misc/python_test_app.py +3 -0
  565. data/packaging/debian/internal/test/misc/ruby_test_app.rb +5 -0
  566. data/packaging/debian/internal/test/misc/test_support.rb +61 -0
  567. data/packaging/debian/internal/test/nginx/vhost.conf +23 -0
  568. data/packaging/debian/internal/test/system_web_server_test.rb +126 -0
  569. data/packaging/debian/internal/test/test.sh +141 -0
  570. data/packaging/debian/jenkins/publish/clear_caches.rb +48 -0
  571. data/packaging/debian/jenkins/publish/publish.sh +69 -0
  572. data/packaging/debian/jenkins/test/test.sh +63 -0
  573. data/packaging/debian/passenger_apt_automation.sublime-project +14 -0
  574. data/packaging/debian/publish +172 -0
  575. data/packaging/debian/shell +116 -0
  576. data/packaging/debian/test +142 -0
  577. metadata +563 -3
  578. metadata.gz.asc +7 -7
  579. 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
+ };