passenger-jmazzi 2.2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (912) hide show
  1. data/INSTALL +6 -0
  2. data/LICENSE +19 -0
  3. data/NEWS +270 -0
  4. data/README +45 -0
  5. data/Rakefile +918 -0
  6. data/benchmark/ApplicationPool.cpp +52 -0
  7. data/benchmark/accept_vs_socketpair_vs_named_pipes.rb +126 -0
  8. data/benchmark/dispatcher.rb +42 -0
  9. data/benchmark/overhead_of_password_checking.rb +81 -0
  10. data/benchmark/socket_connections_vs_persistent_pipe.rb +99 -0
  11. data/benchmark/unix_sockets_vs_pipes.rb +83 -0
  12. data/bin/passenger-config +46 -0
  13. data/bin/passenger-install-apache2-module +224 -0
  14. data/bin/passenger-install-nginx-module +474 -0
  15. data/bin/passenger-make-enterprisey +83 -0
  16. data/bin/passenger-memory-stats +301 -0
  17. data/bin/passenger-spawn-server +68 -0
  18. data/bin/passenger-status +125 -0
  19. data/bin/passenger-stress-test +344 -0
  20. data/debian/compat +1 -0
  21. data/debian/control +21 -0
  22. data/debian/postinst +24 -0
  23. data/debian/prerm +2 -0
  24. data/doc/ApplicationPool algorithm.txt +402 -0
  25. data/doc/Architectural overview.txt +334 -0
  26. data/doc/Doxyfile +241 -0
  27. data/doc/Security of user switching support.txt +197 -0
  28. data/doc/Users guide Apache.txt +1848 -0
  29. data/doc/Users guide Nginx.txt +769 -0
  30. data/doc/definitions.h +5 -0
  31. data/doc/images/by_sa.png +0 -0
  32. data/doc/images/conservative_spawning.png +0 -0
  33. data/doc/images/conservative_spawning.svg +248 -0
  34. data/doc/images/icons/README +5 -0
  35. data/doc/images/icons/callouts/1.png +0 -0
  36. data/doc/images/icons/callouts/10.png +0 -0
  37. data/doc/images/icons/callouts/11.png +0 -0
  38. data/doc/images/icons/callouts/12.png +0 -0
  39. data/doc/images/icons/callouts/13.png +0 -0
  40. data/doc/images/icons/callouts/14.png +0 -0
  41. data/doc/images/icons/callouts/15.png +0 -0
  42. data/doc/images/icons/callouts/2.png +0 -0
  43. data/doc/images/icons/callouts/3.png +0 -0
  44. data/doc/images/icons/callouts/4.png +0 -0
  45. data/doc/images/icons/callouts/5.png +0 -0
  46. data/doc/images/icons/callouts/6.png +0 -0
  47. data/doc/images/icons/callouts/7.png +0 -0
  48. data/doc/images/icons/callouts/8.png +0 -0
  49. data/doc/images/icons/callouts/9.png +0 -0
  50. data/doc/images/icons/caution.png +0 -0
  51. data/doc/images/icons/example.png +0 -0
  52. data/doc/images/icons/home.png +0 -0
  53. data/doc/images/icons/important.png +0 -0
  54. data/doc/images/icons/next.png +0 -0
  55. data/doc/images/icons/note.png +0 -0
  56. data/doc/images/icons/prev.png +0 -0
  57. data/doc/images/icons/tip.png +0 -0
  58. data/doc/images/icons/up.png +0 -0
  59. data/doc/images/icons/warning.png +0 -0
  60. data/doc/images/passenger_architecture.png +0 -0
  61. data/doc/images/passenger_architecture.svg +401 -0
  62. data/doc/images/phusion_banner.png +0 -0
  63. data/doc/images/smart-lv2.png +0 -0
  64. data/doc/images/smart-lv2.svg +320 -0
  65. data/doc/images/spawn_server_architecture.png +0 -0
  66. data/doc/images/spawn_server_architecture.svg +655 -0
  67. data/doc/images/typical_isolated_web_application.png +0 -0
  68. data/doc/images/typical_isolated_web_application.svg +213 -0
  69. data/doc/template/horo.rb +613 -0
  70. data/doc/users_guide_snippets/analysis_and_system_maintenance_tools.txt +144 -0
  71. data/doc/users_guide_snippets/appendix_a_about.txt +13 -0
  72. data/doc/users_guide_snippets/appendix_b_terminology.txt +63 -0
  73. data/doc/users_guide_snippets/appendix_c_spawning_methods.txt +304 -0
  74. data/doc/users_guide_snippets/global_queueing_explained.txt +78 -0
  75. data/doc/users_guide_snippets/rackup_specifications.txt +71 -0
  76. data/doc/users_guide_snippets/rails_spawn_method.txt +48 -0
  77. data/doc/users_guide_snippets/tips.txt +173 -0
  78. data/ext/apache2/Bucket.cpp +190 -0
  79. data/ext/apache2/Bucket.h +87 -0
  80. data/ext/apache2/Configuration.cpp +798 -0
  81. data/ext/apache2/Configuration.h +405 -0
  82. data/ext/apache2/DirectoryMapper.h +296 -0
  83. data/ext/apache2/Hooks.cpp +1617 -0
  84. data/ext/apache2/Hooks.h +45 -0
  85. data/ext/apache2/LICENSE-CNRI.TXT +79 -0
  86. data/ext/apache2/mod_passenger.c +38 -0
  87. data/ext/boost/LICENSE.TXT +23 -0
  88. data/ext/boost/VERSION.TXT +1 -0
  89. data/ext/boost/algorithm/string/case_conv.hpp +176 -0
  90. data/ext/boost/algorithm/string/compare.hpp +199 -0
  91. data/ext/boost/algorithm/string/concept.hpp +83 -0
  92. data/ext/boost/algorithm/string/config.hpp +28 -0
  93. data/ext/boost/algorithm/string/constants.hpp +36 -0
  94. data/ext/boost/algorithm/string/detail/case_conv.hpp +112 -0
  95. data/ext/boost/algorithm/string/detail/find_format.hpp +193 -0
  96. data/ext/boost/algorithm/string/detail/find_format_all.hpp +263 -0
  97. data/ext/boost/algorithm/string/detail/find_format_store.hpp +71 -0
  98. data/ext/boost/algorithm/string/detail/finder.hpp +646 -0
  99. data/ext/boost/algorithm/string/detail/formatter.hpp +94 -0
  100. data/ext/boost/algorithm/string/detail/replace_storage.hpp +159 -0
  101. data/ext/boost/algorithm/string/detail/sequence.hpp +200 -0
  102. data/ext/boost/algorithm/string/detail/util.hpp +106 -0
  103. data/ext/boost/algorithm/string/erase.hpp +844 -0
  104. data/ext/boost/algorithm/string/find_format.hpp +269 -0
  105. data/ext/boost/algorithm/string/finder.hpp +270 -0
  106. data/ext/boost/algorithm/string/formatter.hpp +103 -0
  107. data/ext/boost/algorithm/string/replace.hpp +928 -0
  108. data/ext/boost/algorithm/string/sequence_traits.hpp +193 -0
  109. data/ext/boost/algorithm/string/yes_no_type.hpp +33 -0
  110. data/ext/boost/assert.hpp +50 -0
  111. data/ext/boost/bind.hpp +1689 -0
  112. data/ext/boost/bind/arg.hpp +62 -0
  113. data/ext/boost/bind/bind_cc.hpp +117 -0
  114. data/ext/boost/bind/bind_mf_cc.hpp +227 -0
  115. data/ext/boost/bind/bind_template.hpp +345 -0
  116. data/ext/boost/bind/mem_fn_cc.hpp +103 -0
  117. data/ext/boost/bind/mem_fn_template.hpp +1020 -0
  118. data/ext/boost/bind/placeholders.hpp +68 -0
  119. data/ext/boost/bind/storage.hpp +475 -0
  120. data/ext/boost/call_traits.hpp +24 -0
  121. data/ext/boost/checked_delete.hpp +69 -0
  122. data/ext/boost/concept/assert.hpp +46 -0
  123. data/ext/boost/concept/detail/concept_def.hpp +51 -0
  124. data/ext/boost/concept/detail/concept_undef.hpp +5 -0
  125. data/ext/boost/concept/detail/general.hpp +66 -0
  126. data/ext/boost/concept/detail/has_constraints.hpp +48 -0
  127. data/ext/boost/concept/usage.hpp +43 -0
  128. data/ext/boost/concept_check.hpp +988 -0
  129. data/ext/boost/config.hpp +70 -0
  130. data/ext/boost/config/abi/borland_prefix.hpp +27 -0
  131. data/ext/boost/config/abi/borland_suffix.hpp +12 -0
  132. data/ext/boost/config/abi/msvc_prefix.hpp +8 -0
  133. data/ext/boost/config/abi/msvc_suffix.hpp +8 -0
  134. data/ext/boost/config/abi_prefix.hpp +25 -0
  135. data/ext/boost/config/abi_suffix.hpp +26 -0
  136. data/ext/boost/config/auto_link.hpp +368 -0
  137. data/ext/boost/config/compiler/borland.hpp +209 -0
  138. data/ext/boost/config/compiler/comeau.hpp +59 -0
  139. data/ext/boost/config/compiler/common_edg.hpp +62 -0
  140. data/ext/boost/config/compiler/compaq_cxx.hpp +19 -0
  141. data/ext/boost/config/compiler/digitalmars.hpp +67 -0
  142. data/ext/boost/config/compiler/gcc.hpp +149 -0
  143. data/ext/boost/config/compiler/gcc_xml.hpp +30 -0
  144. data/ext/boost/config/compiler/greenhills.hpp +28 -0
  145. data/ext/boost/config/compiler/hp_acc.hpp +95 -0
  146. data/ext/boost/config/compiler/intel.hpp +162 -0
  147. data/ext/boost/config/compiler/kai.hpp +35 -0
  148. data/ext/boost/config/compiler/metrowerks.hpp +111 -0
  149. data/ext/boost/config/compiler/mpw.hpp +51 -0
  150. data/ext/boost/config/compiler/pgi.hpp +25 -0
  151. data/ext/boost/config/compiler/sgi_mipspro.hpp +28 -0
  152. data/ext/boost/config/compiler/sunpro_cc.hpp +98 -0
  153. data/ext/boost/config/compiler/vacpp.hpp +60 -0
  154. data/ext/boost/config/compiler/visualc.hpp +191 -0
  155. data/ext/boost/config/no_tr1/complex.hpp +28 -0
  156. data/ext/boost/config/no_tr1/functional.hpp +28 -0
  157. data/ext/boost/config/no_tr1/memory.hpp +28 -0
  158. data/ext/boost/config/no_tr1/utility.hpp +28 -0
  159. data/ext/boost/config/platform/aix.hpp +33 -0
  160. data/ext/boost/config/platform/amigaos.hpp +15 -0
  161. data/ext/boost/config/platform/beos.hpp +26 -0
  162. data/ext/boost/config/platform/bsd.hpp +73 -0
  163. data/ext/boost/config/platform/cygwin.hpp +51 -0
  164. data/ext/boost/config/platform/hpux.hpp +84 -0
  165. data/ext/boost/config/platform/irix.hpp +31 -0
  166. data/ext/boost/config/platform/linux.hpp +98 -0
  167. data/ext/boost/config/platform/macos.hpp +78 -0
  168. data/ext/boost/config/platform/qnxnto.hpp +31 -0
  169. data/ext/boost/config/platform/solaris.hpp +21 -0
  170. data/ext/boost/config/platform/win32.hpp +58 -0
  171. data/ext/boost/config/posix_features.hpp +95 -0
  172. data/ext/boost/config/requires_threads.hpp +92 -0
  173. data/ext/boost/config/select_compiler_config.hpp +115 -0
  174. data/ext/boost/config/select_platform_config.hpp +90 -0
  175. data/ext/boost/config/select_stdlib_config.hpp +68 -0
  176. data/ext/boost/config/stdlib/dinkumware.hpp +106 -0
  177. data/ext/boost/config/stdlib/libcomo.hpp +46 -0
  178. data/ext/boost/config/stdlib/libstdcpp3.hpp +73 -0
  179. data/ext/boost/config/stdlib/modena.hpp +30 -0
  180. data/ext/boost/config/stdlib/msl.hpp +59 -0
  181. data/ext/boost/config/stdlib/roguewave.hpp +153 -0
  182. data/ext/boost/config/stdlib/sgi.hpp +111 -0
  183. data/ext/boost/config/stdlib/stlport.hpp +201 -0
  184. data/ext/boost/config/stdlib/vacpp.hpp +18 -0
  185. data/ext/boost/config/suffix.hpp +566 -0
  186. data/ext/boost/config/user.hpp +124 -0
  187. data/ext/boost/cstdint.hpp +449 -0
  188. data/ext/boost/current_function.hpp +67 -0
  189. data/ext/boost/date_time/adjust_functors.hpp +178 -0
  190. data/ext/boost/date_time/c_time.hpp +91 -0
  191. data/ext/boost/date_time/compiler_config.hpp +149 -0
  192. data/ext/boost/date_time/constrained_value.hpp +98 -0
  193. data/ext/boost/date_time/date.hpp +197 -0
  194. data/ext/boost/date_time/date_clock_device.hpp +77 -0
  195. data/ext/boost/date_time/date_defs.hpp +26 -0
  196. data/ext/boost/date_time/date_duration.hpp +147 -0
  197. data/ext/boost/date_time/date_duration_types.hpp +269 -0
  198. data/ext/boost/date_time/date_facet.hpp +775 -0
  199. data/ext/boost/date_time/date_format_simple.hpp +159 -0
  200. data/ext/boost/date_time/date_formatting.hpp +127 -0
  201. data/ext/boost/date_time/date_formatting_limited.hpp +121 -0
  202. data/ext/boost/date_time/date_formatting_locales.hpp +233 -0
  203. data/ext/boost/date_time/date_generator_formatter.hpp +263 -0
  204. data/ext/boost/date_time/date_generator_parser.hpp +329 -0
  205. data/ext/boost/date_time/date_generators.hpp +509 -0
  206. data/ext/boost/date_time/date_iterator.hpp +101 -0
  207. data/ext/boost/date_time/date_names_put.hpp +320 -0
  208. data/ext/boost/date_time/date_parsing.hpp +299 -0
  209. data/ext/boost/date_time/dst_rules.hpp +391 -0
  210. data/ext/boost/date_time/filetime_functions.hpp +78 -0
  211. data/ext/boost/date_time/format_date_parser.hpp +731 -0
  212. data/ext/boost/date_time/gregorian/conversion.hpp +73 -0
  213. data/ext/boost/date_time/gregorian/formatters.hpp +162 -0
  214. data/ext/boost/date_time/gregorian/formatters_limited.hpp +81 -0
  215. data/ext/boost/date_time/gregorian/greg_calendar.hpp +47 -0
  216. data/ext/boost/date_time/gregorian/greg_date.hpp +135 -0
  217. data/ext/boost/date_time/gregorian/greg_day.hpp +57 -0
  218. data/ext/boost/date_time/gregorian/greg_day_of_year.hpp +38 -0
  219. data/ext/boost/date_time/gregorian/greg_duration.hpp +38 -0
  220. data/ext/boost/date_time/gregorian/greg_duration_types.hpp +34 -0
  221. data/ext/boost/date_time/gregorian/greg_month.hpp +105 -0
  222. data/ext/boost/date_time/gregorian/greg_weekday.hpp +66 -0
  223. data/ext/boost/date_time/gregorian/greg_year.hpp +53 -0
  224. data/ext/boost/date_time/gregorian/greg_ymd.hpp +33 -0
  225. data/ext/boost/date_time/gregorian/gregorian.hpp +38 -0
  226. data/ext/boost/date_time/gregorian/gregorian_io.hpp +777 -0
  227. data/ext/boost/date_time/gregorian/gregorian_types.hpp +109 -0
  228. data/ext/boost/date_time/gregorian/parsers.hpp +91 -0
  229. data/ext/boost/date_time/gregorian_calendar.hpp +70 -0
  230. data/ext/boost/date_time/gregorian_calendar.ipp +219 -0
  231. data/ext/boost/date_time/int_adapter.hpp +507 -0
  232. data/ext/boost/date_time/iso_format.hpp +303 -0
  233. data/ext/boost/date_time/locale_config.hpp +31 -0
  234. data/ext/boost/date_time/microsec_time_clock.hpp +205 -0
  235. data/ext/boost/date_time/parse_format_base.hpp +29 -0
  236. data/ext/boost/date_time/period.hpp +377 -0
  237. data/ext/boost/date_time/period_formatter.hpp +196 -0
  238. data/ext/boost/date_time/period_parser.hpp +196 -0
  239. data/ext/boost/date_time/posix_time/conversion.hpp +93 -0
  240. data/ext/boost/date_time/posix_time/date_duration_operators.hpp +114 -0
  241. data/ext/boost/date_time/posix_time/posix_time.hpp +39 -0
  242. data/ext/boost/date_time/posix_time/posix_time_config.hpp +178 -0
  243. data/ext/boost/date_time/posix_time/posix_time_duration.hpp +82 -0
  244. data/ext/boost/date_time/posix_time/posix_time_io.hpp +246 -0
  245. data/ext/boost/date_time/posix_time/posix_time_system.hpp +68 -0
  246. data/ext/boost/date_time/posix_time/posix_time_types.hpp +55 -0
  247. data/ext/boost/date_time/posix_time/ptime.hpp +65 -0
  248. data/ext/boost/date_time/posix_time/time_formatters.hpp +289 -0
  249. data/ext/boost/date_time/posix_time/time_parsers.hpp +44 -0
  250. data/ext/boost/date_time/posix_time/time_period.hpp +29 -0
  251. data/ext/boost/date_time/special_defs.hpp +25 -0
  252. data/ext/boost/date_time/special_values_formatter.hpp +96 -0
  253. data/ext/boost/date_time/special_values_parser.hpp +159 -0
  254. data/ext/boost/date_time/string_convert.hpp +33 -0
  255. data/ext/boost/date_time/string_parse_tree.hpp +278 -0
  256. data/ext/boost/date_time/strings_from_facet.hpp +123 -0
  257. data/ext/boost/date_time/time.hpp +190 -0
  258. data/ext/boost/date_time/time_clock.hpp +83 -0
  259. data/ext/boost/date_time/time_defs.hpp +33 -0
  260. data/ext/boost/date_time/time_duration.hpp +281 -0
  261. data/ext/boost/date_time/time_facet.hpp +1263 -0
  262. data/ext/boost/date_time/time_formatting_streams.hpp +119 -0
  263. data/ext/boost/date_time/time_iterator.hpp +52 -0
  264. data/ext/boost/date_time/time_parsing.hpp +321 -0
  265. data/ext/boost/date_time/time_resolution_traits.hpp +140 -0
  266. data/ext/boost/date_time/time_system_counted.hpp +254 -0
  267. data/ext/boost/date_time/time_system_split.hpp +213 -0
  268. data/ext/boost/date_time/wrapping_int.hpp +163 -0
  269. data/ext/boost/date_time/year_month_day.hpp +45 -0
  270. data/ext/boost/detail/atomic_count.hpp +124 -0
  271. data/ext/boost/detail/atomic_count_gcc.hpp +68 -0
  272. data/ext/boost/detail/atomic_count_gcc_x86.hpp +84 -0
  273. data/ext/boost/detail/atomic_count_pthreads.hpp +96 -0
  274. data/ext/boost/detail/atomic_count_solaris.hpp +59 -0
  275. data/ext/boost/detail/atomic_count_sync.hpp +57 -0
  276. data/ext/boost/detail/atomic_count_win32.hpp +63 -0
  277. data/ext/boost/detail/bad_weak_ptr.hpp +59 -0
  278. data/ext/boost/detail/call_traits.hpp +164 -0
  279. data/ext/boost/detail/endian.hpp +73 -0
  280. data/ext/boost/detail/indirect_traits.hpp +487 -0
  281. data/ext/boost/detail/iterator.hpp +494 -0
  282. data/ext/boost/detail/lcast_precision.hpp +184 -0
  283. data/ext/boost/detail/limits.hpp +449 -0
  284. data/ext/boost/detail/reference_content.hpp +141 -0
  285. data/ext/boost/detail/shared_count.hpp +375 -0
  286. data/ext/boost/detail/sp_counted_base.hpp +81 -0
  287. data/ext/boost/detail/sp_counted_base_acc_ia64.hpp +150 -0
  288. data/ext/boost/detail/sp_counted_base_cw_ppc.hpp +170 -0
  289. data/ext/boost/detail/sp_counted_base_cw_x86.hpp +158 -0
  290. data/ext/boost/detail/sp_counted_base_gcc_ia64.hpp +157 -0
  291. data/ext/boost/detail/sp_counted_base_gcc_ppc.hpp +181 -0
  292. data/ext/boost/detail/sp_counted_base_gcc_sparc.hpp +166 -0
  293. data/ext/boost/detail/sp_counted_base_gcc_x86.hpp +173 -0
  294. data/ext/boost/detail/sp_counted_base_nt.hpp +107 -0
  295. data/ext/boost/detail/sp_counted_base_pt.hpp +135 -0
  296. data/ext/boost/detail/sp_counted_base_solaris.hpp +113 -0
  297. data/ext/boost/detail/sp_counted_base_sync.hpp +151 -0
  298. data/ext/boost/detail/sp_counted_base_w32.hpp +130 -0
  299. data/ext/boost/detail/sp_counted_impl.hpp +231 -0
  300. data/ext/boost/detail/sp_typeinfo.hpp +83 -0
  301. data/ext/boost/detail/workaround.hpp +202 -0
  302. data/ext/boost/enable_shared_from_this.hpp +73 -0
  303. data/ext/boost/function.hpp +66 -0
  304. data/ext/boost/function/detail/function_iterate.hpp +16 -0
  305. data/ext/boost/function/detail/maybe_include.hpp +267 -0
  306. data/ext/boost/function/detail/prologue.hpp +25 -0
  307. data/ext/boost/function/function_base.hpp +762 -0
  308. data/ext/boost/function/function_template.hpp +969 -0
  309. data/ext/boost/function_equal.hpp +28 -0
  310. data/ext/boost/get_pointer.hpp +29 -0
  311. data/ext/boost/implicit_cast.hpp +29 -0
  312. data/ext/boost/integer_traits.hpp +236 -0
  313. data/ext/boost/io/ios_state.hpp +431 -0
  314. data/ext/boost/io_fwd.hpp +67 -0
  315. data/ext/boost/is_placeholder.hpp +31 -0
  316. data/ext/boost/iterator.hpp +59 -0
  317. data/ext/boost/iterator/detail/config_def.hpp +135 -0
  318. data/ext/boost/iterator/detail/config_undef.hpp +25 -0
  319. data/ext/boost/iterator/detail/enable_if.hpp +86 -0
  320. data/ext/boost/iterator/detail/facade_iterator_category.hpp +200 -0
  321. data/ext/boost/iterator/detail/minimum_category.hpp +116 -0
  322. data/ext/boost/iterator/interoperable.hpp +50 -0
  323. data/ext/boost/iterator/iterator_adaptor.hpp +366 -0
  324. data/ext/boost/iterator/iterator_categories.hpp +188 -0
  325. data/ext/boost/iterator/iterator_facade.hpp +879 -0
  326. data/ext/boost/iterator/iterator_traits.hpp +92 -0
  327. data/ext/boost/iterator/reverse_iterator.hpp +69 -0
  328. data/ext/boost/iterator/transform_iterator.hpp +188 -0
  329. data/ext/boost/lexical_cast.hpp +1205 -0
  330. data/ext/boost/limits.hpp +146 -0
  331. data/ext/boost/mem_fn.hpp +389 -0
  332. data/ext/boost/mpl/always.hpp +39 -0
  333. data/ext/boost/mpl/and.hpp +60 -0
  334. data/ext/boost/mpl/apply.hpp +229 -0
  335. data/ext/boost/mpl/apply_fwd.hpp +107 -0
  336. data/ext/boost/mpl/apply_wrap.hpp +203 -0
  337. data/ext/boost/mpl/arg.hpp +131 -0
  338. data/ext/boost/mpl/arg_fwd.hpp +28 -0
  339. data/ext/boost/mpl/assert.hpp +370 -0
  340. data/ext/boost/mpl/aux_/adl_barrier.hpp +48 -0
  341. data/ext/boost/mpl/aux_/arg_typedef.hpp +31 -0
  342. data/ext/boost/mpl/aux_/arity.hpp +39 -0
  343. data/ext/boost/mpl/aux_/arity_spec.hpp +67 -0
  344. data/ext/boost/mpl/aux_/common_name_wknd.hpp +34 -0
  345. data/ext/boost/mpl/aux_/config/adl.hpp +40 -0
  346. data/ext/boost/mpl/aux_/config/arrays.hpp +30 -0
  347. data/ext/boost/mpl/aux_/config/bind.hpp +33 -0
  348. data/ext/boost/mpl/aux_/config/compiler.hpp +64 -0
  349. data/ext/boost/mpl/aux_/config/ctps.hpp +30 -0
  350. data/ext/boost/mpl/aux_/config/dtp.hpp +46 -0
  351. data/ext/boost/mpl/aux_/config/eti.hpp +47 -0
  352. data/ext/boost/mpl/aux_/config/gcc.hpp +23 -0
  353. data/ext/boost/mpl/aux_/config/has_apply.hpp +32 -0
  354. data/ext/boost/mpl/aux_/config/has_xxx.hpp +33 -0
  355. data/ext/boost/mpl/aux_/config/integral.hpp +38 -0
  356. data/ext/boost/mpl/aux_/config/intel.hpp +21 -0
  357. data/ext/boost/mpl/aux_/config/lambda.hpp +32 -0
  358. data/ext/boost/mpl/aux_/config/msvc.hpp +21 -0
  359. data/ext/boost/mpl/aux_/config/msvc_typename.hpp +26 -0
  360. data/ext/boost/mpl/aux_/config/nttp.hpp +41 -0
  361. data/ext/boost/mpl/aux_/config/overload_resolution.hpp +29 -0
  362. data/ext/boost/mpl/aux_/config/pp_counter.hpp +26 -0
  363. data/ext/boost/mpl/aux_/config/preprocessor.hpp +39 -0
  364. data/ext/boost/mpl/aux_/config/static_constant.hpp +25 -0
  365. data/ext/boost/mpl/aux_/config/ttp.hpp +41 -0
  366. data/ext/boost/mpl/aux_/config/use_preprocessed.hpp +19 -0
  367. data/ext/boost/mpl/aux_/config/workaround.hpp +19 -0
  368. data/ext/boost/mpl/aux_/full_lambda.hpp +354 -0
  369. data/ext/boost/mpl/aux_/has_apply.hpp +32 -0
  370. data/ext/boost/mpl/aux_/has_type.hpp +23 -0
  371. data/ext/boost/mpl/aux_/include_preprocessed.hpp +42 -0
  372. data/ext/boost/mpl/aux_/integral_wrapper.hpp +93 -0
  373. data/ext/boost/mpl/aux_/lambda_arity_param.hpp +25 -0
  374. data/ext/boost/mpl/aux_/lambda_support.hpp +169 -0
  375. data/ext/boost/mpl/aux_/msvc_never_true.hpp +34 -0
  376. data/ext/boost/mpl/aux_/na.hpp +95 -0
  377. data/ext/boost/mpl/aux_/na_assert.hpp +34 -0
  378. data/ext/boost/mpl/aux_/na_fwd.hpp +31 -0
  379. data/ext/boost/mpl/aux_/na_spec.hpp +175 -0
  380. data/ext/boost/mpl/aux_/nested_type_wknd.hpp +48 -0
  381. data/ext/boost/mpl/aux_/nttp_decl.hpp +35 -0
  382. data/ext/boost/mpl/aux_/preprocessed/gcc/and.hpp +69 -0
  383. data/ext/boost/mpl/aux_/preprocessed/gcc/apply.hpp +169 -0
  384. data/ext/boost/mpl/aux_/preprocessed/gcc/apply_fwd.hpp +52 -0
  385. data/ext/boost/mpl/aux_/preprocessed/gcc/apply_wrap.hpp +84 -0
  386. data/ext/boost/mpl/aux_/preprocessed/gcc/arg.hpp +123 -0
  387. data/ext/boost/mpl/aux_/preprocessed/gcc/bind.hpp +561 -0
  388. data/ext/boost/mpl/aux_/preprocessed/gcc/bind_fwd.hpp +52 -0
  389. data/ext/boost/mpl/aux_/preprocessed/gcc/full_lambda.hpp +558 -0
  390. data/ext/boost/mpl/aux_/preprocessed/gcc/or.hpp +69 -0
  391. data/ext/boost/mpl/aux_/preprocessed/gcc/placeholders.hpp +105 -0
  392. data/ext/boost/mpl/aux_/preprocessed/gcc/quote.hpp +123 -0
  393. data/ext/boost/mpl/aux_/preprocessed/gcc/template_arity.hpp +101 -0
  394. data/ext/boost/mpl/aux_/preprocessor/def_params_tail.hpp +105 -0
  395. data/ext/boost/mpl/aux_/preprocessor/enum.hpp +62 -0
  396. data/ext/boost/mpl/aux_/preprocessor/filter_params.hpp +28 -0
  397. data/ext/boost/mpl/aux_/preprocessor/params.hpp +65 -0
  398. data/ext/boost/mpl/aux_/preprocessor/sub.hpp +65 -0
  399. data/ext/boost/mpl/aux_/static_cast.hpp +27 -0
  400. data/ext/boost/mpl/aux_/template_arity.hpp +189 -0
  401. data/ext/boost/mpl/aux_/template_arity_fwd.hpp +23 -0
  402. data/ext/boost/mpl/aux_/type_wrapper.hpp +47 -0
  403. data/ext/boost/mpl/aux_/value_wknd.hpp +89 -0
  404. data/ext/boost/mpl/aux_/yes_no.hpp +58 -0
  405. data/ext/boost/mpl/bind.hpp +551 -0
  406. data/ext/boost/mpl/bind_fwd.hpp +99 -0
  407. data/ext/boost/mpl/bool.hpp +39 -0
  408. data/ext/boost/mpl/bool_fwd.hpp +33 -0
  409. data/ext/boost/mpl/eval_if.hpp +71 -0
  410. data/ext/boost/mpl/has_xxx.hpp +272 -0
  411. data/ext/boost/mpl/identity.hpp +45 -0
  412. data/ext/boost/mpl/if.hpp +135 -0
  413. data/ext/boost/mpl/int.hpp +22 -0
  414. data/ext/boost/mpl/int_fwd.hpp +27 -0
  415. data/ext/boost/mpl/integral_c.hpp +51 -0
  416. data/ext/boost/mpl/integral_c_fwd.hpp +32 -0
  417. data/ext/boost/mpl/integral_c_tag.hpp +26 -0
  418. data/ext/boost/mpl/lambda.hpp +29 -0
  419. data/ext/boost/mpl/lambda_fwd.hpp +57 -0
  420. data/ext/boost/mpl/limits/arity.hpp +21 -0
  421. data/ext/boost/mpl/logical.hpp +21 -0
  422. data/ext/boost/mpl/next.hpp +19 -0
  423. data/ext/boost/mpl/next_prior.hpp +49 -0
  424. data/ext/boost/mpl/not.hpp +51 -0
  425. data/ext/boost/mpl/or.hpp +61 -0
  426. data/ext/boost/mpl/placeholders.hpp +100 -0
  427. data/ext/boost/mpl/protect.hpp +55 -0
  428. data/ext/boost/mpl/quote.hpp +140 -0
  429. data/ext/boost/mpl/size_t.hpp +25 -0
  430. data/ext/boost/mpl/size_t_fwd.hpp +28 -0
  431. data/ext/boost/mpl/void.hpp +76 -0
  432. data/ext/boost/mpl/void_fwd.hpp +26 -0
  433. data/ext/boost/next_prior.hpp +51 -0
  434. data/ext/boost/non_type.hpp +27 -0
  435. data/ext/boost/noncopyable.hpp +36 -0
  436. data/ext/boost/none.hpp +28 -0
  437. data/ext/boost/none_t.hpp +24 -0
  438. data/ext/boost/operators.hpp +943 -0
  439. data/ext/boost/optional.hpp +18 -0
  440. data/ext/boost/optional/optional.hpp +922 -0
  441. data/ext/boost/optional/optional_fwd.hpp +22 -0
  442. data/ext/boost/preprocessor/arithmetic/add.hpp +51 -0
  443. data/ext/boost/preprocessor/arithmetic/dec.hpp +288 -0
  444. data/ext/boost/preprocessor/arithmetic/inc.hpp +288 -0
  445. data/ext/boost/preprocessor/arithmetic/sub.hpp +50 -0
  446. data/ext/boost/preprocessor/array/data.hpp +28 -0
  447. data/ext/boost/preprocessor/array/elem.hpp +29 -0
  448. data/ext/boost/preprocessor/array/size.hpp +28 -0
  449. data/ext/boost/preprocessor/cat.hpp +35 -0
  450. data/ext/boost/preprocessor/comma_if.hpp +17 -0
  451. data/ext/boost/preprocessor/config/config.hpp +70 -0
  452. data/ext/boost/preprocessor/control/detail/while.hpp +536 -0
  453. data/ext/boost/preprocessor/control/expr_iif.hpp +31 -0
  454. data/ext/boost/preprocessor/control/if.hpp +30 -0
  455. data/ext/boost/preprocessor/control/iif.hpp +34 -0
  456. data/ext/boost/preprocessor/control/while.hpp +312 -0
  457. data/ext/boost/preprocessor/debug/error.hpp +33 -0
  458. data/ext/boost/preprocessor/detail/auto_rec.hpp +293 -0
  459. data/ext/boost/preprocessor/detail/check.hpp +48 -0
  460. data/ext/boost/preprocessor/detail/is_binary.hpp +30 -0
  461. data/ext/boost/preprocessor/empty.hpp +17 -0
  462. data/ext/boost/preprocessor/enum.hpp +17 -0
  463. data/ext/boost/preprocessor/enum_params.hpp +17 -0
  464. data/ext/boost/preprocessor/facilities/empty.hpp +21 -0
  465. data/ext/boost/preprocessor/facilities/identity.hpp +23 -0
  466. data/ext/boost/preprocessor/identity.hpp +17 -0
  467. data/ext/boost/preprocessor/inc.hpp +17 -0
  468. data/ext/boost/preprocessor/iterate.hpp +17 -0
  469. data/ext/boost/preprocessor/iteration/detail/bounds/lower1.hpp +99 -0
  470. data/ext/boost/preprocessor/iteration/detail/bounds/upper1.hpp +99 -0
  471. data/ext/boost/preprocessor/iteration/detail/iter/forward1.hpp +1342 -0
  472. data/ext/boost/preprocessor/iteration/iterate.hpp +82 -0
  473. data/ext/boost/preprocessor/list/adt.hpp +73 -0
  474. data/ext/boost/preprocessor/list/append.hpp +40 -0
  475. data/ext/boost/preprocessor/list/detail/fold_left.hpp +279 -0
  476. data/ext/boost/preprocessor/list/detail/fold_right.hpp +277 -0
  477. data/ext/boost/preprocessor/list/fold_left.hpp +303 -0
  478. data/ext/boost/preprocessor/list/fold_right.hpp +40 -0
  479. data/ext/boost/preprocessor/list/for_each_i.hpp +65 -0
  480. data/ext/boost/preprocessor/list/reverse.hpp +40 -0
  481. data/ext/boost/preprocessor/list/transform.hpp +49 -0
  482. data/ext/boost/preprocessor/logical/and.hpp +30 -0
  483. data/ext/boost/preprocessor/logical/bitand.hpp +38 -0
  484. data/ext/boost/preprocessor/logical/bool.hpp +288 -0
  485. data/ext/boost/preprocessor/logical/compl.hpp +36 -0
  486. data/ext/boost/preprocessor/punctuation/comma.hpp +21 -0
  487. data/ext/boost/preprocessor/punctuation/comma_if.hpp +31 -0
  488. data/ext/boost/preprocessor/repeat.hpp +17 -0
  489. data/ext/boost/preprocessor/repetition/detail/for.hpp +536 -0
  490. data/ext/boost/preprocessor/repetition/enum.hpp +66 -0
  491. data/ext/boost/preprocessor/repetition/enum_binary_params.hpp +54 -0
  492. data/ext/boost/preprocessor/repetition/enum_params.hpp +41 -0
  493. data/ext/boost/preprocessor/repetition/for.hpp +306 -0
  494. data/ext/boost/preprocessor/repetition/repeat.hpp +825 -0
  495. data/ext/boost/preprocessor/repetition/repeat_from_to.hpp +87 -0
  496. data/ext/boost/preprocessor/seq/elem.hpp +304 -0
  497. data/ext/boost/preprocessor/seq/enum.hpp +288 -0
  498. data/ext/boost/preprocessor/seq/for_each_i.hpp +61 -0
  499. data/ext/boost/preprocessor/seq/seq.hpp +44 -0
  500. data/ext/boost/preprocessor/seq/size.hpp +548 -0
  501. data/ext/boost/preprocessor/slot/detail/def.hpp +49 -0
  502. data/ext/boost/preprocessor/slot/detail/shared.hpp +247 -0
  503. data/ext/boost/preprocessor/slot/slot.hpp +32 -0
  504. data/ext/boost/preprocessor/stringize.hpp +33 -0
  505. data/ext/boost/preprocessor/tuple/eat.hpp +57 -0
  506. data/ext/boost/preprocessor/tuple/elem.hpp +385 -0
  507. data/ext/boost/preprocessor/tuple/rem.hpp +72 -0
  508. data/ext/boost/preprocessor/tuple/to_list.hpp +62 -0
  509. data/ext/boost/range/as_literal.hpp +131 -0
  510. data/ext/boost/range/begin.hpp +132 -0
  511. data/ext/boost/range/config.hpp +54 -0
  512. data/ext/boost/range/const_iterator.hpp +64 -0
  513. data/ext/boost/range/detail/common.hpp +117 -0
  514. data/ext/boost/range/detail/implementation_help.hpp +99 -0
  515. data/ext/boost/range/detail/sfinae.hpp +77 -0
  516. data/ext/boost/range/detail/str_types.hpp +38 -0
  517. data/ext/boost/range/difference_type.hpp +29 -0
  518. data/ext/boost/range/distance.hpp +34 -0
  519. data/ext/boost/range/empty.hpp +34 -0
  520. data/ext/boost/range/end.hpp +131 -0
  521. data/ext/boost/range/functions.hpp +27 -0
  522. data/ext/boost/range/iterator.hpp +72 -0
  523. data/ext/boost/range/iterator_range.hpp +643 -0
  524. data/ext/boost/range/mutable_iterator.hpp +64 -0
  525. data/ext/boost/range/rbegin.hpp +65 -0
  526. data/ext/boost/range/rend.hpp +65 -0
  527. data/ext/boost/range/reverse_iterator.hpp +40 -0
  528. data/ext/boost/range/size.hpp +36 -0
  529. data/ext/boost/range/size_type.hpp +78 -0
  530. data/ext/boost/range/value_type.hpp +34 -0
  531. data/ext/boost/ref.hpp +178 -0
  532. data/ext/boost/shared_ptr.hpp +619 -0
  533. data/ext/boost/src/pthread/exceptions.cpp +146 -0
  534. data/ext/boost/src/pthread/once.cpp +51 -0
  535. data/ext/boost/src/pthread/thread.cpp +709 -0
  536. data/ext/boost/src/pthread/timeconv.inl +130 -0
  537. data/ext/boost/src/tss_null.cpp +34 -0
  538. data/ext/boost/src/win32/exceptions.cpp +124 -0
  539. data/ext/boost/src/win32/thread.cpp +629 -0
  540. data/ext/boost/src/win32/timeconv.inl +130 -0
  541. data/ext/boost/src/win32/tss_dll.cpp +72 -0
  542. data/ext/boost/src/win32/tss_pe.cpp +269 -0
  543. data/ext/boost/static_assert.hpp +122 -0
  544. data/ext/boost/thread.hpp +21 -0
  545. data/ext/boost/thread/condition.hpp +16 -0
  546. data/ext/boost/thread/condition_variable.hpp +21 -0
  547. data/ext/boost/thread/detail/config.hpp +94 -0
  548. data/ext/boost/thread/detail/move.hpp +33 -0
  549. data/ext/boost/thread/detail/platform.hpp +71 -0
  550. data/ext/boost/thread/exceptions.hpp +109 -0
  551. data/ext/boost/thread/locks.hpp +589 -0
  552. data/ext/boost/thread/mutex.hpp +21 -0
  553. data/ext/boost/thread/once.hpp +29 -0
  554. data/ext/boost/thread/pthread/condition_variable.hpp +184 -0
  555. data/ext/boost/thread/pthread/condition_variable_fwd.hpp +66 -0
  556. data/ext/boost/thread/pthread/mutex.hpp +211 -0
  557. data/ext/boost/thread/pthread/once.hpp +85 -0
  558. data/ext/boost/thread/pthread/pthread_mutex_scoped_lock.hpp +50 -0
  559. data/ext/boost/thread/pthread/recursive_mutex.hpp +249 -0
  560. data/ext/boost/thread/pthread/thread.hpp +339 -0
  561. data/ext/boost/thread/pthread/thread_data.hpp +102 -0
  562. data/ext/boost/thread/pthread/timespec.hpp +28 -0
  563. data/ext/boost/thread/pthread/tss.hpp +103 -0
  564. data/ext/boost/thread/recursive_mutex.hpp +21 -0
  565. data/ext/boost/thread/thread.hpp +22 -0
  566. data/ext/boost/thread/thread_time.hpp +46 -0
  567. data/ext/boost/thread/tss.hpp +18 -0
  568. data/ext/boost/thread/xtime.hpp +88 -0
  569. data/ext/boost/throw_exception.hpp +46 -0
  570. data/ext/boost/token_functions.hpp +621 -0
  571. data/ext/boost/token_iterator.hpp +128 -0
  572. data/ext/boost/tokenizer.hpp +98 -0
  573. data/ext/boost/type.hpp +18 -0
  574. data/ext/boost/type_traits/add_const.hpp +47 -0
  575. data/ext/boost/type_traits/add_pointer.hpp +72 -0
  576. data/ext/boost/type_traits/add_reference.hpp +89 -0
  577. data/ext/boost/type_traits/alignment_of.hpp +100 -0
  578. data/ext/boost/type_traits/broken_compiler_spec.hpp +117 -0
  579. data/ext/boost/type_traits/composite_traits.hpp +29 -0
  580. data/ext/boost/type_traits/config.hpp +76 -0
  581. data/ext/boost/type_traits/conversion_traits.hpp +17 -0
  582. data/ext/boost/type_traits/detail/bool_trait_def.hpp +173 -0
  583. data/ext/boost/type_traits/detail/bool_trait_undef.hpp +27 -0
  584. data/ext/boost/type_traits/detail/cv_traits_impl.hpp +97 -0
  585. data/ext/boost/type_traits/detail/false_result.hpp +28 -0
  586. data/ext/boost/type_traits/detail/ice_and.hpp +35 -0
  587. data/ext/boost/type_traits/detail/ice_eq.hpp +36 -0
  588. data/ext/boost/type_traits/detail/ice_not.hpp +31 -0
  589. data/ext/boost/type_traits/detail/ice_or.hpp +34 -0
  590. data/ext/boost/type_traits/detail/is_function_ptr_helper.hpp +220 -0
  591. data/ext/boost/type_traits/detail/is_mem_fun_pointer_impl.hpp +817 -0
  592. data/ext/boost/type_traits/detail/size_t_trait_def.hpp +58 -0
  593. data/ext/boost/type_traits/detail/size_t_trait_undef.hpp +16 -0
  594. data/ext/boost/type_traits/detail/template_arity_spec.hpp +31 -0
  595. data/ext/boost/type_traits/detail/type_trait_def.hpp +61 -0
  596. data/ext/boost/type_traits/detail/type_trait_undef.hpp +19 -0
  597. data/ext/boost/type_traits/detail/yes_no_type.hpp +26 -0
  598. data/ext/boost/type_traits/function_traits.hpp +236 -0
  599. data/ext/boost/type_traits/has_nothrow_copy.hpp +39 -0
  600. data/ext/boost/type_traits/has_trivial_copy.hpp +49 -0
  601. data/ext/boost/type_traits/ice.hpp +20 -0
  602. data/ext/boost/type_traits/integral_constant.hpp +53 -0
  603. data/ext/boost/type_traits/intrinsics.hpp +153 -0
  604. data/ext/boost/type_traits/is_abstract.hpp +144 -0
  605. data/ext/boost/type_traits/is_arithmetic.hpp +43 -0
  606. data/ext/boost/type_traits/is_array.hpp +90 -0
  607. data/ext/boost/type_traits/is_class.hpp +128 -0
  608. data/ext/boost/type_traits/is_const.hpp +142 -0
  609. data/ext/boost/type_traits/is_convertible.hpp +418 -0
  610. data/ext/boost/type_traits/is_enum.hpp +180 -0
  611. data/ext/boost/type_traits/is_float.hpp +27 -0
  612. data/ext/boost/type_traits/is_function.hpp +95 -0
  613. data/ext/boost/type_traits/is_integral.hpp +73 -0
  614. data/ext/boost/type_traits/is_member_function_pointer.hpp +134 -0
  615. data/ext/boost/type_traits/is_member_pointer.hpp +114 -0
  616. data/ext/boost/type_traits/is_pod.hpp +135 -0
  617. data/ext/boost/type_traits/is_pointer.hpp +160 -0
  618. data/ext/boost/type_traits/is_reference.hpp +116 -0
  619. data/ext/boost/type_traits/is_same.hpp +103 -0
  620. data/ext/boost/type_traits/is_scalar.hpp +55 -0
  621. data/ext/boost/type_traits/is_union.hpp +49 -0
  622. data/ext/boost/type_traits/is_void.hpp +33 -0
  623. data/ext/boost/type_traits/is_volatile.hpp +131 -0
  624. data/ext/boost/type_traits/remove_const.hpp +78 -0
  625. data/ext/boost/type_traits/remove_cv.hpp +61 -0
  626. data/ext/boost/type_traits/remove_pointer.hpp +43 -0
  627. data/ext/boost/type_traits/remove_reference.hpp +50 -0
  628. data/ext/boost/type_traits/type_with_alignment.hpp +288 -0
  629. data/ext/boost/utility.hpp +19 -0
  630. data/ext/boost/utility/addressof.hpp +58 -0
  631. data/ext/boost/utility/base_from_member.hpp +87 -0
  632. data/ext/boost/utility/compare_pointees.hpp +68 -0
  633. data/ext/boost/utility/enable_if.hpp +119 -0
  634. data/ext/boost/visit_each.hpp +29 -0
  635. data/ext/boost/weak_ptr.hpp +188 -0
  636. data/ext/common/Application.h +511 -0
  637. data/ext/common/ApplicationPool.h +205 -0
  638. data/ext/common/ApplicationPoolServer.h +794 -0
  639. data/ext/common/ApplicationPoolServerExecutable.cpp +743 -0
  640. data/ext/common/ApplicationPoolStatusReporter.h +336 -0
  641. data/ext/common/Base64.cpp +143 -0
  642. data/ext/common/Base64.h +57 -0
  643. data/ext/common/CachedFileStat.cpp +62 -0
  644. data/ext/common/CachedFileStat.h +51 -0
  645. data/ext/common/CachedFileStat.hpp +243 -0
  646. data/ext/common/DummySpawnManager.h +108 -0
  647. data/ext/common/Exceptions.h +258 -0
  648. data/ext/common/FileChangeChecker.h +209 -0
  649. data/ext/common/Logging.cpp +65 -0
  650. data/ext/common/Logging.h +123 -0
  651. data/ext/common/MessageChannel.h +615 -0
  652. data/ext/common/PoolOptions.h +355 -0
  653. data/ext/common/SpawnManager.h +561 -0
  654. data/ext/common/StandardApplicationPool.h +821 -0
  655. data/ext/common/StaticString.h +148 -0
  656. data/ext/common/StringListCreator.h +83 -0
  657. data/ext/common/SystemTime.cpp +33 -0
  658. data/ext/common/SystemTime.h +88 -0
  659. data/ext/common/Timer.h +90 -0
  660. data/ext/common/Utils.cpp +681 -0
  661. data/ext/common/Utils.h +497 -0
  662. data/ext/common/Version.h +31 -0
  663. data/ext/nginx/Configuration.c +1098 -0
  664. data/ext/nginx/Configuration.h +71 -0
  665. data/ext/nginx/ContentHandler.c +1225 -0
  666. data/ext/nginx/ContentHandler.h +64 -0
  667. data/ext/nginx/HelperServer.cpp +850 -0
  668. data/ext/nginx/HttpStatusExtractor.h +350 -0
  669. data/ext/nginx/ScgiRequestParser.h +317 -0
  670. data/ext/nginx/StaticContentHandler.c +257 -0
  671. data/ext/nginx/StaticContentHandler.h +37 -0
  672. data/ext/nginx/config +45 -0
  673. data/ext/nginx/ngx_http_passenger_module.c +653 -0
  674. data/ext/nginx/ngx_http_passenger_module.h +72 -0
  675. data/ext/oxt/backtrace.cpp +177 -0
  676. data/ext/oxt/backtrace.hpp +135 -0
  677. data/ext/oxt/detail/backtrace_disabled.hpp +39 -0
  678. data/ext/oxt/detail/backtrace_enabled.hpp +155 -0
  679. data/ext/oxt/detail/spin_lock_gcc_x86.hpp +82 -0
  680. data/ext/oxt/detail/spin_lock_portable.hpp +38 -0
  681. data/ext/oxt/detail/spin_lock_pthreads.hpp +97 -0
  682. data/ext/oxt/detail/tracable_exception_disabled.hpp +46 -0
  683. data/ext/oxt/detail/tracable_exception_enabled.hpp +48 -0
  684. data/ext/oxt/macros.hpp +58 -0
  685. data/ext/oxt/spin_lock.hpp +55 -0
  686. data/ext/oxt/system_calls.cpp +351 -0
  687. data/ext/oxt/system_calls.hpp +244 -0
  688. data/ext/oxt/thread.cpp +32 -0
  689. data/ext/oxt/thread.hpp +335 -0
  690. data/ext/oxt/tracable_exception.cpp +87 -0
  691. data/ext/oxt/tracable_exception.hpp +35 -0
  692. data/ext/phusion_passenger/extconf.rb +36 -0
  693. data/ext/phusion_passenger/native_support.c +308 -0
  694. data/lib/jeweler_spec.rb +86 -0
  695. data/lib/phusion_passenger/abstract_installer.rb +196 -0
  696. data/lib/phusion_passenger/abstract_request_handler.rb +475 -0
  697. data/lib/phusion_passenger/abstract_server.rb +369 -0
  698. data/lib/phusion_passenger/abstract_server_collection.rb +306 -0
  699. data/lib/phusion_passenger/admin_tools.rb +48 -0
  700. data/lib/phusion_passenger/admin_tools/control_process.rb +150 -0
  701. data/lib/phusion_passenger/application.rb +113 -0
  702. data/lib/phusion_passenger/console_text_template.rb +66 -0
  703. data/lib/phusion_passenger/constants.rb +31 -0
  704. data/lib/phusion_passenger/dependencies.rb +425 -0
  705. data/lib/phusion_passenger/events.rb +50 -0
  706. data/lib/phusion_passenger/exceptions.rb +103 -0
  707. data/lib/phusion_passenger/html_template.rb +109 -0
  708. data/lib/phusion_passenger/message_channel.rb +229 -0
  709. data/lib/phusion_passenger/packaging.rb +39 -0
  710. data/lib/phusion_passenger/platform_info.rb +550 -0
  711. data/lib/phusion_passenger/rack/application_spawner.rb +146 -0
  712. data/lib/phusion_passenger/rack/request_handler.rb +122 -0
  713. data/lib/phusion_passenger/railz/application_spawner.rb +412 -0
  714. data/lib/phusion_passenger/railz/cgi_fixed.rb +68 -0
  715. data/lib/phusion_passenger/railz/framework_spawner.rb +334 -0
  716. data/lib/phusion_passenger/railz/request_handler.rb +73 -0
  717. data/lib/phusion_passenger/simple_benchmarking.rb +52 -0
  718. data/lib/phusion_passenger/spawn_manager.rb +372 -0
  719. data/lib/phusion_passenger/templates/apache2/apache_must_be_compiled_with_compatible_mpm.txt.erb +9 -0
  720. data/lib/phusion_passenger/templates/apache2/config_snippets.txt.erb +13 -0
  721. data/lib/phusion_passenger/templates/apache2/deployment_example.txt.erb +23 -0
  722. data/lib/phusion_passenger/templates/apache2/no_write_permission_to_passenger_root.txt.erb +9 -0
  723. data/lib/phusion_passenger/templates/apache2/possible_solutions_for_compilation_and_installation_problems.txt.erb +11 -0
  724. data/lib/phusion_passenger/templates/apache2/run_installer_as_root.txt.erb +8 -0
  725. data/lib/phusion_passenger/templates/apache2/welcome.txt.erb +15 -0
  726. data/lib/phusion_passenger/templates/app_exited_during_initialization.html.erb +14 -0
  727. data/lib/phusion_passenger/templates/app_init_error.html.erb +46 -0
  728. data/lib/phusion_passenger/templates/database_error.html.erb +24 -0
  729. data/lib/phusion_passenger/templates/error_layout.css +97 -0
  730. data/lib/phusion_passenger/templates/error_layout.html.erb +39 -0
  731. data/lib/phusion_passenger/templates/framework_init_error.html.erb +10 -0
  732. data/lib/phusion_passenger/templates/general_error.html.erb +8 -0
  733. data/lib/phusion_passenger/templates/invalid_app_root.html.erb +9 -0
  734. data/lib/phusion_passenger/templates/load_error.html.erb +6 -0
  735. data/lib/phusion_passenger/templates/nginx/ask_for_extra_configure_flags.txt.erb +8 -0
  736. data/lib/phusion_passenger/templates/nginx/cannot_write_to_dir.txt.erb +11 -0
  737. data/lib/phusion_passenger/templates/nginx/config_snippets.txt.erb +17 -0
  738. data/lib/phusion_passenger/templates/nginx/config_snippets_inserted.txt.erb +20 -0
  739. data/lib/phusion_passenger/templates/nginx/confirm_extra_configure_flags.txt.erb +5 -0
  740. data/lib/phusion_passenger/templates/nginx/deployment_example.txt.erb +22 -0
  741. data/lib/phusion_passenger/templates/nginx/pcre_could_not_be_downloaded.txt.erb +11 -0
  742. data/lib/phusion_passenger/templates/nginx/pcre_could_not_be_extracted.txt.erb +11 -0
  743. data/lib/phusion_passenger/templates/nginx/possible_solutions_for_compilation_and_installation_problems.txt.erb +11 -0
  744. data/lib/phusion_passenger/templates/nginx/possible_solutions_for_download_and_extraction_problems.txt.erb +20 -0
  745. data/lib/phusion_passenger/templates/nginx/query_download_and_install.txt.erb +21 -0
  746. data/lib/phusion_passenger/templates/nginx/run_installer_as_root.txt.erb +8 -0
  747. data/lib/phusion_passenger/templates/nginx/welcome.txt.erb +15 -0
  748. data/lib/phusion_passenger/templates/version_not_found.html.erb +6 -0
  749. data/lib/phusion_passenger/utils.rb +611 -0
  750. data/lib/phusion_passenger/utils/rewindable_input.rb +116 -0
  751. data/lib/phusion_passenger/wsgi/application_spawner.rb +104 -0
  752. data/lib/phusion_passenger/wsgi/request_handler.py +199 -0
  753. data/man/passenger-config.1 +29 -0
  754. data/man/passenger-make-enterprisey.8 +23 -0
  755. data/man/passenger-memory-stats.8 +33 -0
  756. data/man/passenger-status.8 +43 -0
  757. data/man/passenger-stress-test.1 +43 -0
  758. data/misc/copy_boost_headers.rb +125 -0
  759. data/misc/find_owner_pipe_leaks.rb +128 -0
  760. data/misc/rake/cplusplus.rb +57 -0
  761. data/misc/rake/extensions.rb +182 -0
  762. data/misc/rake/gempackagetask.rb +99 -0
  763. data/misc/rake/packagetask.rb +186 -0
  764. data/misc/rake/rdoctask.rb +209 -0
  765. data/misc/render_error_pages.rb +116 -0
  766. data/test/ApplicationPoolServerTest.cpp +114 -0
  767. data/test/ApplicationPoolServer_ApplicationPoolTest.cpp +33 -0
  768. data/test/ApplicationPoolTest.cpp +599 -0
  769. data/test/Base64Test.cpp +48 -0
  770. data/test/CachedFileStatTest.cpp +402 -0
  771. data/test/CxxTestMain.cpp +143 -0
  772. data/test/FileChangeCheckerTest.cpp +331 -0
  773. data/test/HttpStatusExtractorTest.cpp +198 -0
  774. data/test/MessageChannelTest.cpp +312 -0
  775. data/test/PoolOptionsTest.cpp +117 -0
  776. data/test/ScgiRequestParserTest.cpp +337 -0
  777. data/test/SpawnManagerTest.cpp +64 -0
  778. data/test/StandardApplicationPoolTest.cpp +27 -0
  779. data/test/StaticStringTest.cpp +51 -0
  780. data/test/SystemTimeTest.cpp +37 -0
  781. data/test/UtilsTest.cpp +257 -0
  782. data/test/config.yml.example +30 -0
  783. data/test/integration_tests/apache2_tests.rb +595 -0
  784. data/test/integration_tests/hello_world_rack_spec.rb +36 -0
  785. data/test/integration_tests/hello_world_wsgi_spec.rb +41 -0
  786. data/test/integration_tests/mycook_spec.rb +192 -0
  787. data/test/integration_tests/nginx_tests.rb +151 -0
  788. data/test/oxt/backtrace_test.cpp +128 -0
  789. data/test/oxt/oxt_test_main.cpp +25 -0
  790. data/test/oxt/syscall_interruption_test.cpp +38 -0
  791. data/test/ruby/abstract_request_handler_spec.rb +85 -0
  792. data/test/ruby/abstract_server_collection_spec.rb +246 -0
  793. data/test/ruby/abstract_server_spec.rb +51 -0
  794. data/test/ruby/application_spec.rb +43 -0
  795. data/test/ruby/message_channel_spec.rb +170 -0
  796. data/test/ruby/rack/application_spawner_spec.rb +99 -0
  797. data/test/ruby/rails/application_spawner_spec.rb +159 -0
  798. data/test/ruby/rails/framework_spawner_spec.rb +133 -0
  799. data/test/ruby/rails/minimal_spawner_spec.rb +93 -0
  800. data/test/ruby/rails/spawner_error_handling_spec.rb +107 -0
  801. data/test/ruby/rails/spawner_privilege_lowering_spec.rb +97 -0
  802. data/test/ruby/spawn_manager_spec.rb +205 -0
  803. data/test/ruby/spawn_server_spec.rb +26 -0
  804. data/test/ruby/utils_spec.rb +335 -0
  805. data/test/ruby/wsgi/application_spawner_spec.rb +54 -0
  806. data/test/stub/apache2/httpd.conf.erb +81 -0
  807. data/test/stub/apache2/mime.types +748 -0
  808. data/test/stub/garbage1.dat +0 -0
  809. data/test/stub/garbage2.dat +0 -0
  810. data/test/stub/garbage3.dat +0 -0
  811. data/test/stub/http_request.yml +23 -0
  812. data/test/stub/message_channel.rb +9 -0
  813. data/test/stub/message_channel_2.rb +10 -0
  814. data/test/stub/message_channel_3.rb +17 -0
  815. data/test/stub/nginx/koi-utf +109 -0
  816. data/test/stub/nginx/koi-win +103 -0
  817. data/test/stub/nginx/mime.types +70 -0
  818. data/test/stub/nginx/nginx.conf.erb +57 -0
  819. data/test/stub/nginx/win-utf +126 -0
  820. data/test/stub/rack/config.ru +4 -0
  821. data/test/stub/rack/public/rack.jpg +0 -0
  822. data/test/stub/rails_apps/foobar/app/controllers/application.rb +12 -0
  823. data/test/stub/rails_apps/foobar/app/controllers/bar_controller_1.rb +5 -0
  824. data/test/stub/rails_apps/foobar/app/controllers/bar_controller_2.rb +5 -0
  825. data/test/stub/rails_apps/foobar/app/controllers/foo_controller.rb +21 -0
  826. data/test/stub/rails_apps/foobar/app/helpers/application_helper.rb +3 -0
  827. data/test/stub/rails_apps/foobar/config/boot.rb +108 -0
  828. data/test/stub/rails_apps/foobar/config/database.yml +19 -0
  829. data/test/stub/rails_apps/foobar/config/environment.rb +59 -0
  830. data/test/stub/rails_apps/foobar/config/environments/development.rb +17 -0
  831. data/test/stub/rails_apps/foobar/config/environments/production.rb +18 -0
  832. data/test/stub/rails_apps/foobar/config/initializers/inflections.rb +10 -0
  833. data/test/stub/rails_apps/foobar/config/initializers/mime_types.rb +5 -0
  834. data/test/stub/rails_apps/foobar/config/routes.rb +35 -0
  835. data/test/stub/rails_apps/mycook/app/controllers/application.rb +12 -0
  836. data/test/stub/rails_apps/mycook/app/controllers/recipes_controller.rb +5 -0
  837. data/test/stub/rails_apps/mycook/app/controllers/uploads_controller.rb +15 -0
  838. data/test/stub/rails_apps/mycook/app/controllers/welcome_controller.rb +71 -0
  839. data/test/stub/rails_apps/mycook/app/helpers/application_helper.rb +3 -0
  840. data/test/stub/rails_apps/mycook/app/views/layouts/default.rhtml +26 -0
  841. data/test/stub/rails_apps/mycook/app/views/recipes/create.rhtml +13 -0
  842. data/test/stub/rails_apps/mycook/app/views/recipes/index.rhtml +3 -0
  843. data/test/stub/rails_apps/mycook/app/views/recipes/new.rhtml +8 -0
  844. data/test/stub/rails_apps/mycook/app/views/uploads/index.rhtml +1 -0
  845. data/test/stub/rails_apps/mycook/app/views/uploads/new.html.erb +8 -0
  846. data/test/stub/rails_apps/mycook/app/views/welcome/cached.rhtml +1 -0
  847. data/test/stub/rails_apps/mycook/app/views/welcome/index.rhtml +20 -0
  848. data/test/stub/rails_apps/mycook/config/boot.rb +108 -0
  849. data/test/stub/rails_apps/mycook/config/database.yml +19 -0
  850. data/test/stub/rails_apps/mycook/config/environment.rb +61 -0
  851. data/test/stub/rails_apps/mycook/config/environments/development.rb +18 -0
  852. data/test/stub/rails_apps/mycook/config/environments/production.rb +19 -0
  853. data/test/stub/rails_apps/mycook/config/initializers/inflections.rb +10 -0
  854. data/test/stub/rails_apps/mycook/config/initializers/mime_types.rb +5 -0
  855. data/test/stub/rails_apps/mycook/config/routes.rb +38 -0
  856. data/test/stub/rails_apps/mycook/log/useless.txt +1 -0
  857. data/test/stub/rails_apps/mycook/public/404.html +30 -0
  858. data/test/stub/rails_apps/mycook/public/422.html +30 -0
  859. data/test/stub/rails_apps/mycook/public/500.html +30 -0
  860. data/test/stub/rails_apps/mycook/public/dispatch.cgi +10 -0
  861. data/test/stub/rails_apps/mycook/public/dispatch.fcgi +24 -0
  862. data/test/stub/rails_apps/mycook/public/dispatch.rb +10 -0
  863. data/test/stub/rails_apps/mycook/public/favicon.ico +0 -0
  864. data/test/stub/rails_apps/mycook/public/images/angrywizard.gif +0 -0
  865. data/test/stub/rails_apps/mycook/public/images/cookbook.gif +0 -0
  866. data/test/stub/rails_apps/mycook/public/images/header.png +0 -0
  867. data/test/stub/rails_apps/mycook/public/images/rails.png +0 -0
  868. data/test/stub/rails_apps/mycook/public/javascripts/application.js +2 -0
  869. data/test/stub/rails_apps/mycook/public/javascripts/controls.js +963 -0
  870. data/test/stub/rails_apps/mycook/public/javascripts/dragdrop.js +972 -0
  871. data/test/stub/rails_apps/mycook/public/javascripts/effects.js +1120 -0
  872. data/test/stub/rails_apps/mycook/public/javascripts/prototype.js +4225 -0
  873. data/test/stub/rails_apps/mycook/public/robots.txt +5 -0
  874. data/test/stub/rails_apps/mycook/public/uploads.html +26 -0
  875. data/test/stub/rails_apps/mycook/public/welcome/cached.html +26 -0
  876. data/test/stub/rails_apps/mycook/sites/some.site/public/uploads.html +26 -0
  877. data/test/stub/rails_apps/mycook/sites/some.site/public/welcome/cached.html +26 -0
  878. data/test/stub/rails_apps/mycook/tmp/cache/useless.txt +1 -0
  879. data/test/stub/rails_apps/mycook/tmp/pids/useless.txt +1 -0
  880. data/test/stub/rails_apps/mycook/tmp/sessions/useless.txt +1 -0
  881. data/test/stub/rails_apps/mycook/tmp/sockets/useless.txt +1 -0
  882. data/test/stub/spawn_server.rb +20 -0
  883. data/test/stub/upload_data.txt +494 -0
  884. data/test/stub/vendor_rails/minimal/README +1 -0
  885. data/test/stub/vendor_rails/minimal/actionmailer/lib/action_mailer.rb +0 -0
  886. data/test/stub/vendor_rails/minimal/actionpack/lib/action_controller.rb +19 -0
  887. data/test/stub/vendor_rails/minimal/actionpack/lib/action_pack.rb +0 -0
  888. data/test/stub/vendor_rails/minimal/actionpack/lib/action_view.rb +0 -0
  889. data/test/stub/vendor_rails/minimal/activerecord/lib/active_record.rb +7 -0
  890. data/test/stub/vendor_rails/minimal/activeresource/lib/active_resource.rb +0 -0
  891. data/test/stub/vendor_rails/minimal/activesupport/lib/active_support.rb +17 -0
  892. data/test/stub/vendor_rails/minimal/activesupport/lib/active_support/whiny_nil.rb +0 -0
  893. data/test/stub/vendor_rails/minimal/railties/lib/dispatcher.rb +0 -0
  894. data/test/stub/vendor_rails/minimal/railties/lib/initializer.rb +52 -0
  895. data/test/stub/vendor_rails/minimal/railties/lib/ruby_version_check.rb +1 -0
  896. data/test/stub/wsgi/passenger_wsgi.py +3 -0
  897. data/test/stub/wsgi/public/wsgi-snake.jpg +0 -0
  898. data/test/stub/zsfa/header.png +0 -0
  899. data/test/stub/zsfa/index.html +14 -0
  900. data/test/stub/zsfa/zsfa.png +0 -0
  901. data/test/support/Support.cpp +84 -0
  902. data/test/support/Support.h +118 -0
  903. data/test/support/apache2_controller.rb +250 -0
  904. data/test/support/config.rb +38 -0
  905. data/test/support/multipart.rb +62 -0
  906. data/test/support/nginx_controller.rb +98 -0
  907. data/test/support/run_rspec_tests.rb +10 -0
  908. data/test/support/test_helper.rb +207 -0
  909. data/test/support/tut.h +1234 -0
  910. data/test/support/tut_reporter.h +256 -0
  911. data/test/support/valgrind.h +2539 -0
  912. metadata +1078 -0
@@ -0,0 +1,71 @@
1
+ /*
2
+ * Copyright (C) Igor Sysoev
3
+ * Copyright (C) 2007 Manlio Perillo (manlio.perillo@gmail.com)
4
+ * Copyright (C) 2008, 2009 Phusion
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions
8
+ * are met:
9
+ * 1. Redistributions of source code must retain the above copyright
10
+ * notice, this list of conditions and the following disclaimer.
11
+ * 2. Redistributions in binary form must reproduce the above copyright
12
+ * notice, this list of conditions and the following disclaimer in the
13
+ * documentation and/or other materials provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
+ * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
19
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25
+ * SUCH DAMAGE.
26
+ */
27
+
28
+ #ifndef _PASSENGER_NGINX_CONFIGURATION_H_
29
+ #define _PASSENGER_NGINX_CONFIGURATION_H_
30
+
31
+ #include <ngx_config.h>
32
+ #include <ngx_http.h>
33
+
34
+ typedef struct {
35
+ ngx_http_upstream_conf_t upstream;
36
+ ngx_str_t index;
37
+ ngx_array_t *flushes;
38
+ ngx_array_t *vars_len;
39
+ ngx_array_t *vars;
40
+ ngx_array_t *vars_source;
41
+
42
+ ngx_flag_t enabled;
43
+ ngx_flag_t use_global_queue;
44
+ ngx_str_t environment;
45
+ ngx_str_t spawn_method;
46
+ ngx_int_t framework_spawner_idle_time;
47
+ ngx_int_t app_spawner_idle_time;
48
+ ngx_array_t *base_uris;
49
+ } passenger_loc_conf_t;
50
+
51
+ typedef struct {
52
+ ngx_str_t root_dir;
53
+ ngx_str_t ruby;
54
+ ngx_uint_t log_level;
55
+ ngx_uint_t max_pool_size;
56
+ ngx_uint_t max_instances_per_app;
57
+ ngx_uint_t pool_idle_time;
58
+ ngx_flag_t user_switching;
59
+ ngx_str_t default_user;
60
+ } passenger_main_conf_t;
61
+
62
+ extern const ngx_command_t passenger_commands[];
63
+ extern passenger_main_conf_t passenger_main_conf;
64
+
65
+ void *passenger_create_main_conf(ngx_conf_t *cf);
66
+ char *passenger_init_main_conf(ngx_conf_t *cf, void *conf_pointer);
67
+ void *passenger_create_loc_conf(ngx_conf_t *cf);
68
+ char *passenger_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child);
69
+
70
+ #endif /* _PASSENGER_NGINX_CONFIGURATION_H_ */
71
+
@@ -0,0 +1,1225 @@
1
+ /*
2
+ * Copyright (C) Igor Sysoev
3
+ * Copyright (C) 2007 Manlio Perillo (manlio.perillo@gmail.com)
4
+ * Copyright (C) 2008, 2009 Phusion
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions
8
+ * are met:
9
+ * 1. Redistributions of source code must retain the above copyright
10
+ * notice, this list of conditions and the following disclaimer.
11
+ * 2. Redistributions in binary form must reproduce the above copyright
12
+ * notice, this list of conditions and the following disclaimer in the
13
+ * documentation and/or other materials provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
+ * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
19
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25
+ * SUCH DAMAGE.
26
+ */
27
+
28
+ #include <nginx.h>
29
+ #include "ngx_http_passenger_module.h"
30
+ #include "ContentHandler.h"
31
+ #include "StaticContentHandler.h"
32
+ #include "Configuration.h"
33
+ #include "../common/Version.h"
34
+
35
+
36
+ #define NGX_HTTP_SCGI_PARSE_NO_HEADER 20
37
+
38
+ typedef enum {
39
+ FT_ERROR,
40
+ FT_FILE,
41
+ FT_DIRECTORY,
42
+ FT_OTHER
43
+ } FileType;
44
+
45
+
46
+ static ngx_int_t reinit_request(ngx_http_request_t *r);
47
+ static ngx_int_t process_status_line(ngx_http_request_t *r);
48
+ static ngx_int_t parse_status_line(ngx_http_request_t *r,
49
+ passenger_context_t *context);
50
+ static ngx_int_t process_header(ngx_http_request_t *r);
51
+ static void abort_request(ngx_http_request_t *r);
52
+ static void finalize_request(ngx_http_request_t *r, ngx_int_t rc);
53
+
54
+
55
+ static void
56
+ uint_to_str(ngx_uint_t i, u_char *str, ngx_uint_t size) {
57
+ ngx_memzero(str, size);
58
+ ngx_snprintf(str, size, "%ui", i);
59
+ }
60
+
61
+ static FileType
62
+ get_file_type(const u_char *filename, unsigned int throttle_rate) {
63
+ struct stat buf;
64
+ int ret;
65
+
66
+ ret = cached_file_stat_perform(passenger_stat_cache,
67
+ (const char *) filename,
68
+ &buf,
69
+ throttle_rate);
70
+ if (ret == 0) {
71
+ if (S_ISREG(buf.st_mode)) {
72
+ return FT_FILE;
73
+ } else if (S_ISDIR(buf.st_mode)) {
74
+ return FT_DIRECTORY;
75
+ } else {
76
+ return FT_OTHER;
77
+ }
78
+ } else {
79
+ return FT_ERROR;
80
+ }
81
+ }
82
+
83
+ static int
84
+ file_exists(const u_char *filename, unsigned int throttle_rate) {
85
+ return get_file_type(filename, throttle_rate) == FT_FILE;
86
+ }
87
+
88
+ static passenger_app_type_t
89
+ detect_application_type(const ngx_str_t *public_dir) {
90
+ u_char filename[NGX_MAX_PATH];
91
+
92
+ ngx_memzero(filename, sizeof(filename));
93
+ ngx_snprintf(filename, sizeof(filename), "%s/%s",
94
+ public_dir->data, "../config.ru");
95
+ if (file_exists(filename, 1)) {
96
+ return AP_RACK;
97
+ }
98
+
99
+ ngx_memzero(filename, sizeof(filename));
100
+ ngx_snprintf(filename, sizeof(filename), "%s/%s",
101
+ public_dir->data, "../config/environment.rb");
102
+ if (file_exists(filename, 1)) {
103
+ return AP_RAILS;
104
+ }
105
+
106
+ ngx_memzero(filename, sizeof(filename));
107
+ ngx_snprintf(filename, sizeof(filename), "%s/%s",
108
+ public_dir->data, "../passenger_wsgi.py");
109
+ if (file_exists(filename, 1)) {
110
+ return AP_WSGI;
111
+ }
112
+
113
+ return AP_NONE;
114
+ }
115
+
116
+ /**
117
+ * Maps the URI for the given request to a page cache file, if possible.
118
+ *
119
+ * @return Whether the URI has been successfully mapped to a page cache file.
120
+ * @param r The corresponding request.
121
+ * @param public_dir The web application's 'public' directory.
122
+ * @param filename The filename that the URI normally maps to.
123
+ * @param filename_len The length of the <tt>filename</tt> string.
124
+ * @param root The size of the root path in <tt>filename</tt>.
125
+ * @param page_cache_file If mapping was successful, then the page cache
126
+ * file's filename will be stored in here.
127
+ * <tt>page_cache_file.data</tt> must already point to
128
+ * a buffer, and <tt>page_cache_file.len</tt> must be set
129
+ * to the size of this buffer, including terminating NUL.
130
+ */
131
+ static int
132
+ map_uri_to_page_cache_file(ngx_http_request_t *r, ngx_str_t *public_dir,
133
+ const u_char *filename, size_t filename_len,
134
+ ngx_str_t *page_cache_file)
135
+ {
136
+ u_char *end;
137
+
138
+ if ((r->method != NGX_HTTP_GET && r->method != NGX_HTTP_HEAD) || filename_len == 0) {
139
+ return 0;
140
+ }
141
+
142
+ /* From this point on we know that filename is not an empty string. */
143
+
144
+ /* Check whether filename is equal to public_dir. filename may also be equal to
145
+ * public_dir + "/" so check for that as well.
146
+ */
147
+ if ((public_dir->len == filename_len && memcmp(public_dir->data, filename,
148
+ filename_len) == 0) ||
149
+ (public_dir->len == filename_len - 1 &&
150
+ filename[filename_len - 1] == '/' &&
151
+ memcmp(public_dir->data, filename, filename_len - 1) == 0)
152
+ ) {
153
+ /* If the URI maps to the 'public' directory (i.e. the request is the
154
+ * base URI) then index.html is the page cache file.
155
+ */
156
+
157
+ if (filename_len + sizeof("/index.html") > page_cache_file->len) {
158
+ /* Page cache filename doesn't fit in the buffer. */
159
+ return 0;
160
+ }
161
+
162
+ end = ngx_copy(page_cache_file->data, filename, filename_len);
163
+ if (filename[filename_len - 1] != '/') {
164
+ end = ngx_copy(end, "/", 1);
165
+ }
166
+ end = ngx_copy(end, "index.html", sizeof("index.html"));
167
+
168
+ } else {
169
+ /* Otherwise, the page cache file is just filename + ".html". */
170
+
171
+ if (filename_len + sizeof(".html") > page_cache_file->len) {
172
+ /* Page cache filename doesn't fit in the buffer. */
173
+ return 0;
174
+ }
175
+
176
+ end = ngx_copy(page_cache_file->data, filename, filename_len);
177
+ end = ngx_copy(end, ".html", sizeof(".html"));
178
+ }
179
+
180
+ if (file_exists(page_cache_file->data, 0)) {
181
+ page_cache_file->len = end - page_cache_file->data - 1;
182
+ return 1;
183
+ } else {
184
+ return 0;
185
+ }
186
+ }
187
+
188
+ static int
189
+ find_base_uri(ngx_http_request_t *r, const passenger_loc_conf_t *loc,
190
+ ngx_str_t *found_base_uri)
191
+ {
192
+ ngx_uint_t i;
193
+ ngx_str_t *base_uris, *base_uri, *uri;
194
+
195
+ if (loc->base_uris == NGX_CONF_UNSET_PTR) {
196
+ return 0;
197
+ } else {
198
+ base_uris = (ngx_str_t *) loc->base_uris->elts;
199
+ for (i = 0; i < loc->base_uris->nelts; i++) {
200
+ base_uri = &base_uris[i];
201
+ uri = &r->uri;
202
+
203
+ if (uri->len == 1 && uri->data[0] == '/') {
204
+ /* Ignore 'passenger_base_uri /' options. Users usually
205
+ * specify this out of ignorance.
206
+ */
207
+ continue;
208
+ }
209
+
210
+ if (( uri->len == base_uri->len
211
+ && ngx_strncmp(uri->data, base_uri->data, uri->len) == 0 )
212
+ || ( uri->len > base_uri->len
213
+ && ngx_strncmp(uri->data, base_uri->data, base_uri->len) == 0
214
+ && uri->data[base_uri->len] == (u_char) '/' )) {
215
+ *found_base_uri = base_uris[i];
216
+ return 1;
217
+ }
218
+ }
219
+ return 0;
220
+ }
221
+ }
222
+
223
+
224
+ static ngx_int_t
225
+ create_request(ngx_http_request_t *r)
226
+ {
227
+ u_char ch;
228
+ u_char buf[sizeof("4294967296")];
229
+ size_t len, size, key_len, val_len, content_length;
230
+ const u_char *app_type_string;
231
+ size_t app_type_string_len;
232
+ u_char framework_spawner_idle_time_string[12];
233
+ u_char app_spawner_idle_time_string[12];
234
+ u_char *end;
235
+ ngx_uint_t i, n;
236
+ ngx_buf_t *b;
237
+ ngx_chain_t *cl, *body;
238
+ ngx_list_part_t *part;
239
+ ngx_table_elt_t *header;
240
+ ngx_http_script_code_pt code;
241
+ ngx_http_script_engine_t e, le;
242
+ passenger_loc_conf_t *slcf;
243
+ passenger_main_conf_t *main_conf;
244
+ passenger_context_t *context;
245
+ ngx_http_script_len_code_pt lcode;
246
+ #if (NGX_HTTP_SSL)
247
+ ngx_http_ssl_srv_conf_t *ssl_conf;
248
+ #endif
249
+
250
+ slcf = ngx_http_get_module_loc_conf(r, ngx_http_passenger_module);
251
+ main_conf = &passenger_main_conf;
252
+ context = ngx_http_get_module_ctx(r, ngx_http_passenger_module);
253
+ if (context == NULL) {
254
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
255
+ }
256
+
257
+ switch (context->app_type) {
258
+ case AP_RAILS:
259
+ app_type_string = (const u_char *) "rails";
260
+ app_type_string_len = sizeof("rails");
261
+ break;
262
+ case AP_RACK:
263
+ app_type_string = (const u_char *) "rack";
264
+ app_type_string_len = sizeof("rack");
265
+ break;
266
+ case AP_WSGI:
267
+ app_type_string = (const u_char *) "wsgi";
268
+ app_type_string_len = sizeof("wsgi");
269
+ break;
270
+ default:
271
+ app_type_string = (const u_char *) "rails";
272
+ app_type_string_len = sizeof("rails");
273
+ break;
274
+ }
275
+
276
+
277
+ /**************************************************
278
+ * Determine the request header length.
279
+ **************************************************/
280
+
281
+ /* Length of the Content-Length header. */
282
+ if (r->headers_in.content_length_n < 0) {
283
+ content_length = 0;
284
+ } else {
285
+ content_length = r->headers_in.content_length_n;
286
+ }
287
+ uint_to_str(content_length, buf, sizeof(buf));
288
+ /* +1 for trailing null */
289
+ len = sizeof("CONTENT_LENGTH") + ngx_strlen(buf) + 1;
290
+
291
+ /* DOCUMENT_ROOT, SCRIPT_NAME, RAILS_RELATIVE_URL_ROOT and PATH_INFO. */
292
+ len += sizeof("DOCUMENT_ROOT") + context->public_dir.len + 1;
293
+ if (context->base_uri.len > 0) {
294
+ len += sizeof("SCRIPT_NAME") + context->base_uri.len + 1;
295
+ len += sizeof("RAILS_RELATIVE_URL_ROOT") +
296
+ context->base_uri.len + 1;
297
+ len += sizeof("PATH_INFO") + r->uri.len - context->base_uri.len + 1;
298
+ } else {
299
+ len += sizeof("SCRIPT_NAME") + sizeof("");
300
+ len += sizeof("PATH_INFO") + r->uri.len + 1;
301
+ }
302
+
303
+ /* Various other HTTP headers. */
304
+ if (r->headers_in.content_type != NULL
305
+ && r->headers_in.content_type->value.len > 0) {
306
+ len += sizeof("CONTENT_TYPE") + r->headers_in.content_type->value.len + 1;
307
+ }
308
+
309
+ #if (NGX_HTTP_SSL)
310
+ ssl_conf = ngx_http_get_module_srv_conf(r, ngx_http_ssl_module);
311
+ if (ssl_conf->enable) {
312
+ len += sizeof("HTTPS") + sizeof("on");
313
+ }
314
+ #endif
315
+
316
+ /* Lengths of Passenger application pool options. */
317
+ if (slcf->use_global_queue) {
318
+ len += sizeof("PASSENGER_USE_GLOBAL_QUEUE") + sizeof("true");
319
+ } else {
320
+ len += sizeof("PASSENGER_USE_GLOBAL_QUEUE") + sizeof("false");
321
+ }
322
+ len += sizeof("PASSENGER_ENVIRONMENT") + slcf->environment.len + 1;
323
+ len += sizeof("PASSENGER_SPAWN_METHOD") + slcf->spawn_method.len + 1;
324
+ len += sizeof("PASSENGER_APP_TYPE") + app_type_string_len;
325
+
326
+ end = ngx_snprintf(framework_spawner_idle_time_string,
327
+ sizeof(framework_spawner_idle_time_string) - 1,
328
+ "%d",
329
+ (slcf->framework_spawner_idle_time == (ngx_int_t) -1) ?
330
+ -1 : slcf->framework_spawner_idle_time);
331
+ *end = '\0';
332
+ len += sizeof("PASSENGER_FRAMEWORK_SPAWNER_IDLE_TIME") +
333
+ ngx_strlen(framework_spawner_idle_time_string) + 1;
334
+
335
+ end = ngx_snprintf(app_spawner_idle_time_string,
336
+ sizeof(app_spawner_idle_time_string) - 1,
337
+ "%d",
338
+ (slcf->app_spawner_idle_time == (ngx_int_t) -1) ?
339
+ -1 : slcf->app_spawner_idle_time);
340
+ *end = '\0';
341
+ len += sizeof("PASSENGER_APP_SPAWNER_IDLE_TIME") +
342
+ ngx_strlen(app_spawner_idle_time_string) + 1;
343
+
344
+ /* Lengths of various CGI variables. */
345
+ if (slcf->vars_len) {
346
+ ngx_memzero(&le, sizeof(ngx_http_script_engine_t));
347
+
348
+ ngx_http_script_flush_no_cacheable_variables(r, slcf->flushes);
349
+ le.flushed = 1;
350
+
351
+ le.ip = slcf->vars_len->elts;
352
+ le.request = r;
353
+
354
+ while (*(uintptr_t *) le.ip) {
355
+
356
+ lcode = *(ngx_http_script_len_code_pt *) le.ip;
357
+ key_len = lcode(&le);
358
+
359
+ for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) {
360
+ lcode = *(ngx_http_script_len_code_pt *) le.ip;
361
+ }
362
+ le.ip += sizeof(uintptr_t);
363
+
364
+ len += key_len + val_len;
365
+ }
366
+ }
367
+
368
+ /* Lengths of HTTP headers. */
369
+ if (slcf->upstream.pass_request_headers) {
370
+
371
+ part = &r->headers_in.headers.part;
372
+ header = part->elts;
373
+
374
+ for (i = 0; /* void */; i++) {
375
+
376
+ if (i >= part->nelts) {
377
+ if (part->next == NULL) {
378
+ break;
379
+ }
380
+
381
+ part = part->next;
382
+ header = part->elts;
383
+ i = 0;
384
+ }
385
+
386
+ len += sizeof("HTTP_") - 1 + header[i].key.len + 1
387
+ + header[i].value.len + 1;
388
+ }
389
+ }
390
+
391
+ /* Trailing dummy header.
392
+ *
393
+ * If the last header value is an empty string, then the buffer
394
+ * will end with "\0\0". For example, if 'SSL_CLIENT_CERT'
395
+ * is the last header and it has an empty value, then the SCGI header
396
+ * will end with:
397
+ *
398
+ * "SSL_CLIENT_CERT\0\0"
399
+ *
400
+ * The data in the buffer will be processed by the AbstractRequestHandler class,
401
+ * which is implemented in Ruby. But it uses Hash[*data.split("\0")] to
402
+ * unserialize the data. Unfortunately String#split will not transform
403
+ * the trailing "\0\0" into an empty string:
404
+ *
405
+ * "SSL_CLIENT_CERT\0\0".split("\0")
406
+ * # => desired result: ["SSL_CLIENT_CERT", ""]
407
+ * # => actual result: ["SSL_CLIENT_CERT"]
408
+ *
409
+ * When that happens, Hash[..] will raise an ArgumentError because
410
+ * data.split("\0") does not return an array with a length that is a
411
+ * multiple of 2.
412
+ *
413
+ * So here, we add a dummy header to prevent situations like that from
414
+ * happening.
415
+ */
416
+ len += sizeof("_") + sizeof("_");
417
+
418
+
419
+ /**************************************************
420
+ * Build the request header data.
421
+ **************************************************/
422
+
423
+ size = passenger_helper_server_password.len +
424
+ /* netstring length + ":" + trailing "," */
425
+ /* note: 10 == sizeof("4294967296") - 1 */
426
+ len + 10 + 1 + 1;
427
+
428
+ b = ngx_create_temp_buf(r->pool, size);
429
+ if (b == NULL) {
430
+ return NGX_ERROR;
431
+ }
432
+
433
+ cl = ngx_alloc_chain_link(r->pool);
434
+ if (cl == NULL) {
435
+ return NGX_ERROR;
436
+ }
437
+
438
+ cl->buf = b;
439
+
440
+ /* Build SCGI header netstring length part. */
441
+ b->last = ngx_copy(b->last, passenger_helper_server_password.data,
442
+ passenger_helper_server_password.len);
443
+
444
+ b->last = ngx_snprintf(b->last, 10, "%ui", len);
445
+ *b->last++ = (u_char) ':';
446
+
447
+ /* Build CONTENT_LENGTH header. This must always be sent, even if 0. */
448
+ b->last = ngx_copy(b->last, "CONTENT_LENGTH",
449
+ sizeof("CONTENT_LENGTH"));
450
+
451
+ b->last = ngx_snprintf(b->last, 10, "%ui", content_length);
452
+ *b->last++ = (u_char) 0;
453
+
454
+ /* Build DOCUMENT_ROOT, SCRIPT_NAME, RAILS_RELATIVE_URL_ROOT and PATH_INFO. */
455
+ b->last = ngx_copy(b->last, "DOCUMENT_ROOT", sizeof("DOCUMENT_ROOT"));
456
+ b->last = ngx_copy(b->last, context->public_dir.data,
457
+ context->public_dir.len + 1);
458
+
459
+ if (context->base_uri.len > 0) {
460
+ b->last = ngx_copy(b->last, "SCRIPT_NAME", sizeof("SCRIPT_NAME"));
461
+ b->last = ngx_copy(b->last, context->base_uri.data,
462
+ context->base_uri.len + 1);
463
+
464
+ b->last = ngx_copy(b->last, "RAILS_RELATIVE_URL_ROOT",
465
+ sizeof("RAILS_RELATIVE_URL_ROOT"));
466
+ b->last = ngx_copy(b->last, context->base_uri.data,
467
+ context->base_uri.len + 1);
468
+
469
+ b->last = ngx_copy(b->last, "PATH_INFO", sizeof("PATH_INFO"));
470
+ b->last = ngx_copy(b->last, r->uri.data + context->base_uri.len,
471
+ r->uri.len - context->base_uri.len);
472
+ b->last = ngx_copy(b->last, "", 1);
473
+ } else {
474
+ b->last = ngx_copy(b->last, "SCRIPT_NAME", sizeof("SCRIPT_NAME"));
475
+ b->last = ngx_copy(b->last, "", sizeof(""));
476
+
477
+ b->last = ngx_copy(b->last, "PATH_INFO", sizeof("PATH_INFO"));
478
+ b->last = ngx_copy(b->last, r->uri.data, r->uri.len);
479
+ b->last = ngx_copy(b->last, "", 1);
480
+ }
481
+
482
+ /* Various other HTTP headers. */
483
+ if (r->headers_in.content_type != NULL
484
+ && r->headers_in.content_type->value.len > 0) {
485
+ b->last = ngx_copy(b->last, "CONTENT_TYPE", sizeof("CONTENT_TYPE"));
486
+ b->last = ngx_copy(b->last, r->headers_in.content_type->value.data,
487
+ r->headers_in.content_type->value.len);
488
+ b->last = ngx_copy(b->last, "", 1);
489
+ }
490
+
491
+ #if (NGX_HTTP_SSL)
492
+ ssl_conf = ngx_http_get_module_srv_conf(r, ngx_http_ssl_module);
493
+ if (ssl_conf->enable) {
494
+ b->last = ngx_copy(b->last, "HTTPS", sizeof("HTTPS"));
495
+ b->last = ngx_copy(b->last, "on", sizeof("on"));
496
+ }
497
+ #endif
498
+
499
+
500
+ /* Build Passenger application pool option headers. */
501
+ b->last = ngx_copy(b->last, "PASSENGER_USE_GLOBAL_QUEUE",
502
+ sizeof("PASSENGER_USE_GLOBAL_QUEUE"));
503
+ if (slcf->use_global_queue) {
504
+ b->last = ngx_copy(b->last, "true", sizeof("true"));
505
+ } else {
506
+ b->last = ngx_copy(b->last, "false", sizeof("false"));
507
+ }
508
+
509
+ b->last = ngx_copy(b->last, "PASSENGER_ENVIRONMENT",
510
+ sizeof("PASSENGER_ENVIRONMENT"));
511
+ b->last = ngx_copy(b->last, slcf->environment.data,
512
+ slcf->environment.len + 1);
513
+
514
+ b->last = ngx_copy(b->last, "PASSENGER_SPAWN_METHOD",
515
+ sizeof("PASSENGER_SPAWN_METHOD"));
516
+ b->last = ngx_copy(b->last, slcf->spawn_method.data,
517
+ slcf->spawn_method.len + 1);
518
+
519
+ b->last = ngx_copy(b->last, "PASSENGER_APP_TYPE",
520
+ sizeof("PASSENGER_APP_TYPE"));
521
+ b->last = ngx_copy(b->last, app_type_string, app_type_string_len);
522
+
523
+ b->last = ngx_copy(b->last, "PASSENGER_FRAMEWORK_SPAWNER_IDLE_TIME",
524
+ sizeof("PASSENGER_FRAMEWORK_SPAWNER_IDLE_TIME"));
525
+ b->last = ngx_copy(b->last, framework_spawner_idle_time_string,
526
+ ngx_strlen(framework_spawner_idle_time_string) + 1);
527
+
528
+ b->last = ngx_copy(b->last, "PASSENGER_APP_SPAWNER_IDLE_TIME",
529
+ sizeof("PASSENGER_APP_SPAWNER_IDLE_TIME"));
530
+ b->last = ngx_copy(b->last, app_spawner_idle_time_string,
531
+ ngx_strlen(app_spawner_idle_time_string) + 1);
532
+
533
+ if (slcf->vars_len) {
534
+ ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
535
+
536
+ e.ip = slcf->vars->elts;
537
+ e.pos = b->last;
538
+ e.request = r;
539
+ e.flushed = 1;
540
+
541
+ le.ip = slcf->vars_len->elts;
542
+
543
+ while (*(uintptr_t *) le.ip) {
544
+
545
+ lcode = *(ngx_http_script_len_code_pt *) le.ip;
546
+ (void) lcode(&le);
547
+
548
+ for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) {
549
+ lcode = *(ngx_http_script_len_code_pt *) le.ip;
550
+ }
551
+ le.ip += sizeof(uintptr_t);
552
+
553
+ while (*(uintptr_t *) e.ip) {
554
+ code = *(ngx_http_script_code_pt *) e.ip;
555
+ code((ngx_http_script_engine_t *) &e);
556
+ }
557
+ e.ip += sizeof(uintptr_t);
558
+ }
559
+
560
+ b->last = e.pos;
561
+ }
562
+
563
+
564
+ if (slcf->upstream.pass_request_headers) {
565
+
566
+ part = &r->headers_in.headers.part;
567
+ header = part->elts;
568
+
569
+ for (i = 0; /* void */; i++) {
570
+
571
+ if (i >= part->nelts) {
572
+ if (part->next == NULL) {
573
+ break;
574
+ }
575
+
576
+ part = part->next;
577
+ header = part->elts;
578
+ i = 0;
579
+ }
580
+
581
+ b->last = ngx_cpymem(b->last, "HTTP_", sizeof("HTTP_") - 1);
582
+
583
+ for (n = 0; n < header[i].key.len; n++) {
584
+ ch = header[i].key.data[n];
585
+
586
+ if (ch >= 'a' && ch <= 'z') {
587
+ ch &= ~0x20;
588
+
589
+ } else if (ch == '-') {
590
+ ch = '_';
591
+ }
592
+
593
+ *b->last++ = ch;
594
+ }
595
+
596
+ *b->last++ = (u_char) 0;
597
+
598
+ b->last = ngx_copy(b->last, header[i].value.data,
599
+ header[i].value.len);
600
+ *b->last++ = (u_char) 0;
601
+ }
602
+ }
603
+
604
+ /* Trailing dummy header. See earlier comment for explanation. */
605
+ b->last = ngx_copy(b->last, "_\0_", sizeof("_\0_"));
606
+
607
+
608
+ *b->last++ = (u_char) ',';
609
+
610
+ if (slcf->upstream.pass_request_body) {
611
+
612
+ body = r->upstream->request_bufs;
613
+ r->upstream->request_bufs = cl;
614
+
615
+ while (body) {
616
+ b = ngx_alloc_buf(r->pool);
617
+ if (b == NULL) {
618
+ return NGX_ERROR;
619
+ }
620
+
621
+ ngx_memcpy(b, body->buf, sizeof(ngx_buf_t));
622
+
623
+ cl->next = ngx_alloc_chain_link(r->pool);
624
+ if (cl->next == NULL) {
625
+ return NGX_ERROR;
626
+ }
627
+
628
+ cl = cl->next;
629
+ cl->buf = b;
630
+
631
+ body = body->next;
632
+ }
633
+
634
+ b->flush = 1;
635
+
636
+ } else {
637
+ r->upstream->request_bufs = cl;
638
+ }
639
+
640
+
641
+ cl->next = NULL;
642
+
643
+ return NGX_OK;
644
+ }
645
+
646
+
647
+ static ngx_int_t
648
+ reinit_request(ngx_http_request_t *r)
649
+ {
650
+ passenger_context_t *context;
651
+
652
+ context = ngx_http_get_module_ctx(r, ngx_http_passenger_module);
653
+
654
+ if (context == NULL) {
655
+ return NGX_OK;
656
+ }
657
+
658
+ context->status = 0;
659
+ context->status_count = 0;
660
+ context->status_start = NULL;
661
+ context->status_end = NULL;
662
+
663
+ r->upstream->process_header = process_status_line;
664
+
665
+ return NGX_OK;
666
+ }
667
+
668
+
669
+ static ngx_int_t
670
+ process_status_line(ngx_http_request_t *r)
671
+ {
672
+ ngx_int_t rc;
673
+ ngx_http_upstream_t *u;
674
+ passenger_context_t *context;
675
+
676
+ context = ngx_http_get_module_ctx(r, ngx_http_passenger_module);
677
+
678
+ if (context == NULL) {
679
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
680
+ }
681
+
682
+ rc = parse_status_line(r, context);
683
+
684
+ if (rc == NGX_AGAIN) {
685
+ return rc;
686
+ }
687
+
688
+ u = r->upstream;
689
+
690
+ if (rc == NGX_HTTP_SCGI_PARSE_NO_HEADER) {
691
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
692
+ "upstream sent no valid HTTP/1.0 header");
693
+
694
+ #if 0
695
+ if (u->accel) {
696
+ return NGX_HTTP_UPSTREAM_INVALID_HEADER;
697
+ }
698
+ #endif
699
+
700
+ r->http_version = NGX_HTTP_VERSION_9;
701
+ u->headers_in.status_n = NGX_HTTP_OK;
702
+ u->state->status = NGX_HTTP_OK;
703
+
704
+ return NGX_OK;
705
+ }
706
+
707
+ u->headers_in.status_n = context->status;
708
+ u->state->status = context->status;
709
+
710
+ u->headers_in.status_line.len = context->status_end - context->status_start;
711
+ u->headers_in.status_line.data = ngx_palloc(r->pool,
712
+ u->headers_in.status_line.len);
713
+ if (u->headers_in.status_line.data == NULL) {
714
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
715
+ }
716
+
717
+ ngx_memcpy(u->headers_in.status_line.data, context->status_start,
718
+ u->headers_in.status_line.len);
719
+
720
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
721
+ "http scgi status %ui \"%V\"",
722
+ u->headers_in.status_n, &u->headers_in.status_line);
723
+
724
+ u->process_header = process_header;
725
+
726
+ return process_header(r);
727
+ }
728
+
729
+
730
+ static ngx_int_t
731
+ parse_status_line(ngx_http_request_t *r, passenger_context_t *context)
732
+ {
733
+ u_char ch;
734
+ u_char *pos;
735
+ ngx_http_upstream_t *u;
736
+ enum {
737
+ sw_start = 0,
738
+ sw_H,
739
+ sw_HT,
740
+ sw_HTT,
741
+ sw_HTTP,
742
+ sw_first_major_digit,
743
+ sw_major_digit,
744
+ sw_first_minor_digit,
745
+ sw_minor_digit,
746
+ sw_status,
747
+ sw_space_after_status,
748
+ sw_status_text,
749
+ sw_almost_done
750
+ } state;
751
+
752
+ u = r->upstream;
753
+
754
+ state = r->state;
755
+
756
+ for (pos = u->buffer.pos; pos < u->buffer.last; pos++) {
757
+ ch = *pos;
758
+
759
+ switch (state) {
760
+
761
+ /* "HTTP/" */
762
+ case sw_start:
763
+ switch (ch) {
764
+ case 'H':
765
+ state = sw_H;
766
+ break;
767
+ default:
768
+ return NGX_HTTP_SCGI_PARSE_NO_HEADER;
769
+ }
770
+ break;
771
+
772
+ case sw_H:
773
+ switch (ch) {
774
+ case 'T':
775
+ state = sw_HT;
776
+ break;
777
+ default:
778
+ return NGX_HTTP_SCGI_PARSE_NO_HEADER;
779
+ }
780
+ break;
781
+
782
+ case sw_HT:
783
+ switch (ch) {
784
+ case 'T':
785
+ state = sw_HTT;
786
+ break;
787
+ default:
788
+ return NGX_HTTP_SCGI_PARSE_NO_HEADER;
789
+ }
790
+ break;
791
+
792
+ case sw_HTT:
793
+ switch (ch) {
794
+ case 'P':
795
+ state = sw_HTTP;
796
+ break;
797
+ default:
798
+ return NGX_HTTP_SCGI_PARSE_NO_HEADER;
799
+ }
800
+ break;
801
+
802
+ case sw_HTTP:
803
+ switch (ch) {
804
+ case '/':
805
+ state = sw_first_major_digit;
806
+ break;
807
+ default:
808
+ return NGX_HTTP_SCGI_PARSE_NO_HEADER;
809
+ }
810
+ break;
811
+
812
+ /* the first digit of major HTTP version */
813
+ case sw_first_major_digit:
814
+ if (ch < '1' || ch > '9') {
815
+ return NGX_HTTP_SCGI_PARSE_NO_HEADER;
816
+ }
817
+
818
+ state = sw_major_digit;
819
+ break;
820
+
821
+ /* the major HTTP version or dot */
822
+ case sw_major_digit:
823
+ if (ch == '.') {
824
+ state = sw_first_minor_digit;
825
+ break;
826
+ }
827
+
828
+ if (ch < '0' || ch > '9') {
829
+ return NGX_HTTP_SCGI_PARSE_NO_HEADER;
830
+ }
831
+
832
+ break;
833
+
834
+ /* the first digit of minor HTTP version */
835
+ case sw_first_minor_digit:
836
+ if (ch < '0' || ch > '9') {
837
+ return NGX_HTTP_SCGI_PARSE_NO_HEADER;
838
+ }
839
+
840
+ state = sw_minor_digit;
841
+ break;
842
+
843
+ /* the minor HTTP version or the end of the request line */
844
+ case sw_minor_digit:
845
+ if (ch == ' ') {
846
+ state = sw_status;
847
+ break;
848
+ }
849
+
850
+ if (ch < '0' || ch > '9') {
851
+ return NGX_HTTP_SCGI_PARSE_NO_HEADER;
852
+ }
853
+
854
+ break;
855
+
856
+ /* HTTP status code */
857
+ case sw_status:
858
+ if (ch == ' ') {
859
+ break;
860
+ }
861
+
862
+ if (ch < '0' || ch > '9') {
863
+ return NGX_HTTP_SCGI_PARSE_NO_HEADER;
864
+ }
865
+
866
+ context->status = context->status * 10 + ch - '0';
867
+
868
+ if (++context->status_count == 3) {
869
+ state = sw_space_after_status;
870
+ context->status_start = pos - 2;
871
+ }
872
+
873
+ break;
874
+
875
+ /* space or end of line */
876
+ case sw_space_after_status:
877
+ switch (ch) {
878
+ case ' ':
879
+ state = sw_status_text;
880
+ break;
881
+ case '.': /* IIS may send 403.1, 403.2, etc */
882
+ state = sw_status_text;
883
+ break;
884
+ case CR:
885
+ state = sw_almost_done;
886
+ break;
887
+ case LF:
888
+ goto done;
889
+ default:
890
+ return NGX_HTTP_SCGI_PARSE_NO_HEADER;
891
+ }
892
+ break;
893
+
894
+ /* any text until end of line */
895
+ case sw_status_text:
896
+ switch (ch) {
897
+ case CR:
898
+ state = sw_almost_done;
899
+
900
+ break;
901
+ case LF:
902
+ goto done;
903
+ }
904
+ break;
905
+
906
+ /* end of status line */
907
+ case sw_almost_done:
908
+ context->status_end = pos - 1;
909
+ switch (ch) {
910
+ case LF:
911
+ goto done;
912
+ default:
913
+ return NGX_HTTP_SCGI_PARSE_NO_HEADER;
914
+ }
915
+ }
916
+ }
917
+
918
+ u->buffer.pos = pos;
919
+ r->state = state;
920
+
921
+ return NGX_AGAIN;
922
+
923
+ done:
924
+
925
+ u->buffer.pos = pos + 1;
926
+
927
+ if (context->status_end == NULL) {
928
+ context->status_end = pos;
929
+ }
930
+
931
+ r->state = sw_start;
932
+
933
+ return NGX_OK;
934
+ }
935
+
936
+
937
+ static ngx_int_t
938
+ process_header(ngx_http_request_t *r)
939
+ {
940
+ ngx_int_t rc;
941
+ ngx_uint_t i;
942
+ ngx_table_elt_t *h;
943
+ ngx_http_upstream_header_t *hh;
944
+ ngx_http_upstream_main_conf_t *umcf;
945
+
946
+ umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module);
947
+
948
+ for ( ;; ) {
949
+
950
+ #if NGINX_VERSION_NUM >= 7000
951
+ rc = ngx_http_parse_header_line(r, &r->upstream->buffer, 1);
952
+ #else
953
+ rc = ngx_http_parse_header_line(r, &r->upstream->buffer);
954
+ #endif
955
+
956
+ if (rc == NGX_OK) {
957
+
958
+ /* a header line has been parsed successfully */
959
+
960
+ h = ngx_list_push(&r->upstream->headers_in.headers);
961
+ if (h == NULL) {
962
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
963
+ }
964
+
965
+ h->hash = r->header_hash;
966
+
967
+ h->key.len = r->header_name_end - r->header_name_start;
968
+ h->value.len = r->header_end - r->header_start;
969
+
970
+ h->key.data = ngx_palloc(r->pool,
971
+ h->key.len + 1 + h->value.len + 1 + h->key.len);
972
+ if (h->key.data == NULL) {
973
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
974
+ }
975
+
976
+ h->value.data = h->key.data + h->key.len + 1;
977
+ h->lowcase_key = h->key.data + h->key.len + 1 + h->value.len + 1;
978
+
979
+ ngx_cpystrn(h->key.data, r->header_name_start, h->key.len + 1);
980
+ ngx_cpystrn(h->value.data, r->header_start, h->value.len + 1);
981
+
982
+ if (h->key.len == r->lowcase_index) {
983
+ ngx_memcpy(h->lowcase_key, r->lowcase_header, h->key.len);
984
+
985
+ } else {
986
+ for (i = 0; i < h->key.len; i++) {
987
+ h->lowcase_key[i] = ngx_tolower(h->key.data[i]);
988
+ }
989
+ }
990
+
991
+ hh = ngx_hash_find(&umcf->headers_in_hash, h->hash,
992
+ h->lowcase_key, h->key.len);
993
+
994
+ if (hh && hh->handler(r, h, hh->offset) != NGX_OK) {
995
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
996
+ }
997
+
998
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
999
+ "http scgi header: \"%V: %V\"",
1000
+ &h->key, &h->value);
1001
+
1002
+ continue;
1003
+ }
1004
+
1005
+ if (rc == NGX_HTTP_PARSE_HEADER_DONE) {
1006
+
1007
+ /* a whole header has been parsed successfully */
1008
+
1009
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1010
+ "http scgi header done");
1011
+
1012
+ /*
1013
+ * if no "Server" and "Date" in header line,
1014
+ * then add the default headers
1015
+ */
1016
+
1017
+ if (r->upstream->headers_in.server == NULL) {
1018
+ h = ngx_list_push(&r->upstream->headers_in.headers);
1019
+ if (h == NULL) {
1020
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
1021
+ }
1022
+
1023
+ h->hash = ngx_hash(ngx_hash(ngx_hash(ngx_hash(
1024
+ ngx_hash('s', 'e'), 'r'), 'v'), 'e'), 'r');
1025
+
1026
+ h->key.len = sizeof("Server") - 1;
1027
+ h->key.data = (u_char *) "Server";
1028
+ h->value.data = (u_char *) (NGINX_VER " + Phusion Passenger " PASSENGER_VERSION " (mod_rails/mod_rack)");
1029
+ h->value.len = ngx_strlen(h->value.data);
1030
+ h->lowcase_key = (u_char *) "server";
1031
+ }
1032
+
1033
+ if (r->upstream->headers_in.date == NULL) {
1034
+ h = ngx_list_push(&r->upstream->headers_in.headers);
1035
+ if (h == NULL) {
1036
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
1037
+ }
1038
+
1039
+ h->hash = ngx_hash(ngx_hash(ngx_hash('d', 'a'), 't'), 'e');
1040
+
1041
+ h->key.len = sizeof("Date") - 1;
1042
+ h->key.data = (u_char *) "Date";
1043
+ h->value.len = 0;
1044
+ h->value.data = NULL;
1045
+ h->lowcase_key = (u_char *) "date";
1046
+ }
1047
+
1048
+ return NGX_OK;
1049
+ }
1050
+
1051
+ if (rc == NGX_AGAIN) {
1052
+ return NGX_AGAIN;
1053
+ }
1054
+
1055
+ /* there was error while a header line parsing */
1056
+
1057
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
1058
+ "upstream sent invalid header");
1059
+
1060
+ return NGX_HTTP_UPSTREAM_INVALID_HEADER;
1061
+ }
1062
+ }
1063
+
1064
+
1065
+ static void
1066
+ abort_request(ngx_http_request_t *r)
1067
+ {
1068
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1069
+ "abort Passenger request");
1070
+ }
1071
+
1072
+
1073
+ static void
1074
+ finalize_request(ngx_http_request_t *r, ngx_int_t rc)
1075
+ {
1076
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1077
+ "finalize Passenger request");
1078
+ }
1079
+
1080
+
1081
+ ngx_int_t
1082
+ passenger_content_handler(ngx_http_request_t *r)
1083
+ {
1084
+ ngx_int_t rc;
1085
+ ngx_http_upstream_t *u;
1086
+ passenger_loc_conf_t *slcf;
1087
+ ngx_str_t path, base_uri;
1088
+ u_char *path_last, *end;
1089
+ u_char root_path_str[NGX_MAX_PATH + 1];
1090
+ ngx_str_t root_path;
1091
+ size_t root, len;
1092
+ u_char page_cache_file_str[NGX_MAX_PATH + 1];
1093
+ ngx_str_t page_cache_file;
1094
+ passenger_context_t *context;
1095
+
1096
+ if (passenger_main_conf.root_dir.len == 0) {
1097
+ return NGX_DECLINED;
1098
+ } else if (r->subrequest_in_memory) {
1099
+ ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
1100
+ "ngx_http_passenger_module does not support "
1101
+ "subrequest in memory");
1102
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
1103
+ }
1104
+
1105
+ slcf = ngx_http_get_module_loc_conf(r, ngx_http_passenger_module);
1106
+
1107
+ /* Let the next content handler take care of this request if Phusion
1108
+ * Passenger is disabled for this URL.
1109
+ */
1110
+ if (!slcf->enabled) {
1111
+ return NGX_DECLINED;
1112
+ }
1113
+
1114
+ /* Let the next content handler take care of this request if this URL
1115
+ * maps to an existing file.
1116
+ */
1117
+ path_last = ngx_http_map_uri_to_path(r, &path, &root, 0);
1118
+ if (path_last != NULL && file_exists(path.data, 0)) {
1119
+ return NGX_DECLINED;
1120
+ }
1121
+
1122
+ /* Create a string containing the root path. This path already
1123
+ * contains a trailing slash.
1124
+ */
1125
+ end = ngx_copy(root_path_str, path.data, root);
1126
+ *end = '\0';
1127
+ root_path.data = root_path_str;
1128
+ root_path.len = root;
1129
+
1130
+
1131
+ context = ngx_pcalloc(r->pool, sizeof(passenger_context_t));
1132
+ if (context == NULL) {
1133
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
1134
+ }
1135
+ ngx_http_set_ctx(r, context, ngx_http_passenger_module);
1136
+
1137
+
1138
+ /* Find the base URI for this web application, if any. */
1139
+ if (find_base_uri(r, slcf, &base_uri)) {
1140
+ /* Store the found base URI in context->public_dir. We infer that the 'public'
1141
+ * directory of the web application is document root + base URI.
1142
+ */
1143
+ len = root_path.len + base_uri.len + 1;
1144
+ context->public_dir.data = ngx_palloc(r->pool, sizeof(u_char) * len);
1145
+ end = ngx_copy(context->public_dir.data, root_path.data, root_path.len);
1146
+ end = ngx_copy(end, base_uri.data, base_uri.len);
1147
+ *end = '\0';
1148
+ context->public_dir.len = len - 1;
1149
+ context->base_uri = base_uri;
1150
+ } else {
1151
+ /* No base URI directives are applicable for this request. So assume that
1152
+ * the web application's public directory is the document root.
1153
+ * context->base_uri is now a NULL string.
1154
+ */
1155
+ len = sizeof(u_char *) * (root_path.len + 1);
1156
+ context->public_dir.data = ngx_palloc(r->pool, len);
1157
+ end = ngx_copy(context->public_dir.data, root_path.data,
1158
+ root_path.len);
1159
+ *end = '\0';
1160
+ context->public_dir.len = root_path.len;
1161
+ }
1162
+
1163
+ /* If there's a corresponding page cache file for this URL, then serve that
1164
+ * file instead.
1165
+ */
1166
+ page_cache_file.data = page_cache_file_str;
1167
+ page_cache_file.len = sizeof(page_cache_file_str);
1168
+ if (map_uri_to_page_cache_file(r, &context->public_dir, path.data,
1169
+ path_last - path.data, &page_cache_file)) {
1170
+ return passenger_static_content_handler(r, &page_cache_file);
1171
+ }
1172
+
1173
+ context->app_type = detect_application_type(&context->public_dir);
1174
+ if (context->app_type == AP_NONE) {
1175
+ return NGX_DECLINED;
1176
+ }
1177
+
1178
+
1179
+ /* Setup upstream stuff and prepare sending the request to the backend. */
1180
+
1181
+ u = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_t));
1182
+ if (u == NULL) {
1183
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
1184
+ }
1185
+
1186
+ #if NGINX_VERSION_NUM >= 7000
1187
+ u->schema = passenger_schema_string;
1188
+ #endif
1189
+
1190
+ u->peer.log = r->connection->log;
1191
+ u->peer.log_error = NGX_ERROR_ERR;
1192
+ #if (NGX_THREADS)
1193
+ u->peer.lock = &r->connection->lock;
1194
+ #endif
1195
+
1196
+ u->output.tag = (ngx_buf_tag_t) &ngx_http_passenger_module;
1197
+
1198
+ u->conf = &slcf->upstream;
1199
+
1200
+ u->create_request = create_request;
1201
+ u->reinit_request = reinit_request;
1202
+ u->process_header = process_status_line;
1203
+ u->abort_request = abort_request;
1204
+ u->finalize_request = finalize_request;
1205
+
1206
+ u->buffering = 0;
1207
+
1208
+ u->pipe = ngx_pcalloc(r->pool, sizeof(ngx_event_pipe_t));
1209
+ if (u->pipe == NULL) {
1210
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
1211
+ }
1212
+
1213
+ u->pipe->input_filter = ngx_event_pipe_copy_input_filter;
1214
+
1215
+ r->upstream = u;
1216
+
1217
+ rc = ngx_http_read_client_request_body(r, ngx_http_upstream_init);
1218
+
1219
+ if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
1220
+ return rc;
1221
+ }
1222
+
1223
+ return NGX_DONE;
1224
+ }
1225
+