passenger 4.0.60 → 5.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of passenger might be problematic. Click here for more details.
- checksums.yaml +8 -8
- checksums.yaml.gz.asc +7 -7
- data.tar.gz.asc +7 -7
- data/.editorconfig +5 -0
- data/.travis.yml +3 -2
- data/CHANGELOG +31 -53
- data/CONTRIBUTING.md +4 -4
- data/CONTRIBUTORS +0 -1
- data/Gemfile +18 -0
- data/Gemfile.lock +41 -0
- data/Rakefile +16 -0
- data/bin/passenger +2 -2
- data/bin/passenger-install-apache2-module +12 -12
- data/bin/passenger-install-nginx-module +9 -14
- data/bin/passenger-status +125 -87
- data/build/agents.rb +112 -140
- data/build/apache2.rb +4 -9
- data/build/basics.rb +5 -3
- data/build/common_library.rb +1 -0
- data/build/cxx_tests.rb +69 -47
- data/build/debian.rb +4 -2
- data/build/documentation.rb +1 -0
- data/build/integration_tests.rb +28 -43
- data/build/misc.rb +0 -18
- data/build/nginx.rb +2 -6
- data/build/packaging.rb +33 -22
- data/build/preprocessor.rb +2 -4
- data/build/ruby_tests.rb +7 -26
- data/build/test_basics.rb +24 -25
- data/debian.template/control.template +2 -2
- data/debian.template/locations.ini.template +2 -3
- data/debian.template/passenger.install.template +2 -2
- data/debian.template/rules.template +1 -1
- data/dev/ci/run_jenkins.sh +0 -1
- data/dev/ci/run_rpm_tests.sh +3 -0
- data/dev/ci/run_travis.sh +63 -17
- data/dev/copy_boost_headers +22 -6
- data/dev/ruby_server.rb +244 -0
- data/dev/vagrant/provision.sh +3 -1
- data/doc/DebuggingAndStressTesting.md +3 -3
- data/doc/Design and Architecture.txt +5 -6
- data/doc/Packaging.txt.md +35 -6
- data/doc/ServerOptimizationGuide.txt.md +339 -0
- data/doc/Users guide Apache.idmap.txt +177 -187
- data/doc/Users guide Apache.txt +143 -219
- data/doc/Users guide Nginx.idmap.txt +166 -166
- data/doc/Users guide Nginx.txt +265 -223
- data/doc/Users guide Standalone.txt +3 -3
- data/doc/templates/markdown.html.erb +37 -6
- data/doc/users_guide_snippets/environment_variables.txt +1 -1
- data/doc/users_guide_snippets/support_information.txt +1 -1
- data/doc/users_guide_snippets/tips.txt +2 -2
- data/ext/apache2/Configuration.cpp +23 -81
- data/ext/apache2/Configuration.hpp +18 -92
- data/ext/apache2/ConfigurationCommands.cpp +64 -15
- data/ext/apache2/ConfigurationCommands.cpp.erb +8 -4
- data/ext/apache2/ConfigurationFields.hpp +12 -0
- data/ext/apache2/ConfigurationSetters.cpp +73 -1
- data/ext/apache2/ConfigurationSetters.cpp.erb +3 -2
- data/ext/apache2/CreateDirConfig.cpp +6 -0
- data/ext/apache2/DirectoryMapper.h +11 -6
- data/ext/apache2/Hooks.cpp +291 -408
- data/ext/apache2/MergeDirConfig.cpp +42 -0
- data/ext/apache2/SetHeaders.cpp +61 -16
- data/ext/apache2/SetHeaders.cpp.erb +9 -7
- data/ext/boost/container/allocator_traits.hpp +400 -0
- data/ext/boost/container/deque.hpp +2012 -0
- data/ext/boost/container/detail/adaptive_node_pool_impl.hpp +874 -0
- data/ext/boost/container/detail/advanced_insert_int.hpp +369 -0
- data/ext/boost/container/detail/algorithms.hpp +84 -0
- data/ext/boost/container/detail/allocation_type.hpp +54 -0
- data/ext/boost/container/detail/allocator_version_traits.hpp +163 -0
- data/ext/boost/container/detail/config_begin.hpp +49 -0
- data/ext/boost/container/detail/config_end.hpp +17 -0
- data/ext/boost/container/detail/destroyers.hpp +365 -0
- data/ext/boost/container/detail/flat_tree.hpp +1055 -0
- data/ext/boost/container/detail/function_detector.hpp +88 -0
- data/ext/boost/container/detail/iterators.hpp +611 -0
- data/ext/boost/container/detail/math_functions.hpp +113 -0
- data/ext/boost/container/detail/memory_util.hpp +83 -0
- data/ext/boost/container/detail/mpl.hpp +160 -0
- data/ext/boost/container/detail/multiallocation_chain.hpp +286 -0
- data/ext/boost/container/detail/node_alloc_holder.hpp +386 -0
- data/ext/boost/container/detail/node_pool_impl.hpp +365 -0
- data/ext/boost/container/detail/pair.hpp +354 -0
- data/ext/boost/container/detail/pool_common.hpp +52 -0
- data/ext/boost/container/detail/preprocessor.hpp +232 -0
- data/ext/boost/container/detail/transform_iterator.hpp +176 -0
- data/ext/boost/container/detail/tree.hpp +1134 -0
- data/ext/boost/container/detail/type_traits.hpp +210 -0
- data/ext/boost/container/detail/utilities.hpp +1141 -0
- data/ext/boost/container/detail/value_init.hpp +45 -0
- data/ext/boost/container/detail/variadic_templates_tools.hpp +153 -0
- data/ext/boost/container/detail/version_type.hpp +92 -0
- data/ext/boost/container/detail/workaround.hpp +44 -0
- data/ext/boost/container/flat_map.hpp +1674 -0
- data/ext/boost/container/flat_set.hpp +1408 -0
- data/ext/boost/container/list.hpp +1475 -0
- data/ext/boost/container/map.hpp +1508 -0
- data/ext/boost/container/scoped_allocator.hpp +1503 -0
- data/ext/boost/container/scoped_allocator_fwd.hpp +83 -0
- data/ext/boost/container/set.hpp +1280 -0
- data/ext/boost/container/slist.hpp +1706 -0
- data/ext/boost/container/stable_vector.hpp +1869 -0
- data/ext/boost/container/static_vector.hpp +1053 -0
- data/ext/boost/container/string.hpp +2856 -0
- data/ext/boost/container/throw_exception.hpp +110 -0
- data/ext/boost/container/vector.hpp +2671 -0
- data/ext/boost/detail/is_xxx.hpp +61 -0
- data/ext/boost/intrusive/any_hook.hpp +344 -0
- data/ext/boost/intrusive/avl_set.hpp +2528 -0
- data/ext/boost/intrusive/avl_set_hook.hpp +297 -0
- data/ext/boost/intrusive/avltree.hpp +1786 -0
- data/ext/boost/intrusive/avltree_algorithms.hpp +968 -0
- data/ext/boost/intrusive/bs_set_hook.hpp +296 -0
- data/ext/boost/intrusive/circular_list_algorithms.hpp +413 -0
- data/ext/boost/intrusive/circular_slist_algorithms.hpp +404 -0
- data/ext/boost/intrusive/derivation_value_traits.hpp +70 -0
- data/ext/boost/intrusive/detail/any_node_and_algorithms.hpp +297 -0
- data/ext/boost/intrusive/detail/assert.hpp +41 -0
- data/ext/boost/intrusive/detail/avltree_node.hpp +197 -0
- data/ext/boost/intrusive/detail/clear_on_destructor_base.hpp +36 -0
- data/ext/boost/intrusive/detail/common_slist_algorithms.hpp +102 -0
- data/ext/boost/intrusive/detail/config_begin.hpp +52 -0
- data/ext/boost/intrusive/detail/config_end.hpp +15 -0
- data/ext/boost/intrusive/detail/ebo_functor_holder.hpp +95 -0
- data/ext/boost/intrusive/detail/function_detector.hpp +88 -0
- data/ext/boost/intrusive/detail/generic_hook.hpp +209 -0
- data/ext/boost/intrusive/detail/has_member_function_callable_with.hpp +357 -0
- data/ext/boost/intrusive/detail/hashtable_node.hpp +249 -0
- data/ext/boost/intrusive/detail/is_stateful_value_traits.hpp +77 -0
- data/ext/boost/intrusive/detail/list_node.hpp +196 -0
- data/ext/boost/intrusive/detail/memory_util.hpp +288 -0
- data/ext/boost/intrusive/detail/mpl.hpp +383 -0
- data/ext/boost/intrusive/detail/parent_from_member.hpp +97 -0
- data/ext/boost/intrusive/detail/preprocessor.hpp +52 -0
- data/ext/boost/intrusive/detail/rbtree_node.hpp +201 -0
- data/ext/boost/intrusive/detail/slist_node.hpp +166 -0
- data/ext/boost/intrusive/detail/transform_iterator.hpp +173 -0
- data/ext/boost/intrusive/detail/tree_algorithms.hpp +1742 -0
- data/ext/boost/intrusive/detail/tree_node.hpp +199 -0
- data/ext/boost/intrusive/detail/utilities.hpp +858 -0
- data/ext/boost/intrusive/detail/workaround.hpp +22 -0
- data/ext/boost/intrusive/hashtable.hpp +3110 -0
- data/ext/boost/intrusive/intrusive_fwd.hpp +542 -0
- data/ext/boost/intrusive/linear_slist_algorithms.hpp +327 -0
- data/ext/boost/intrusive/link_mode.hpp +46 -0
- data/ext/boost/intrusive/list.hpp +1525 -0
- data/ext/boost/intrusive/list_hook.hpp +290 -0
- data/ext/boost/intrusive/member_value_traits.hpp +70 -0
- data/ext/boost/intrusive/options.hpp +810 -0
- data/ext/boost/intrusive/parent_from_member.hpp +42 -0
- data/ext/boost/intrusive/pointer_plus_bits.hpp +86 -0
- data/ext/boost/intrusive/pointer_traits.hpp +265 -0
- data/ext/boost/intrusive/priority_compare.hpp +39 -0
- data/ext/boost/intrusive/rbtree.hpp +1785 -0
- data/ext/boost/intrusive/rbtree_algorithms.hpp +934 -0
- data/ext/boost/intrusive/set.hpp +2554 -0
- data/ext/boost/intrusive/set_hook.hpp +300 -0
- data/ext/boost/intrusive/sg_set.hpp +2601 -0
- data/ext/boost/intrusive/sgtree.hpp +2009 -0
- data/ext/boost/intrusive/sgtree_algorithms.hpp +807 -0
- data/ext/boost/intrusive/slist.hpp +2219 -0
- data/ext/boost/intrusive/slist_hook.hpp +294 -0
- data/ext/boost/intrusive/splay_set.hpp +2575 -0
- data/ext/boost/intrusive/splay_set_hook.hpp +292 -0
- data/ext/boost/intrusive/splaytree.hpp +1784 -0
- data/ext/boost/intrusive/splaytree_algorithms.hpp +1008 -0
- data/ext/boost/intrusive/treap.hpp +1882 -0
- data/ext/boost/intrusive/treap_algorithms.hpp +919 -0
- data/ext/boost/intrusive/treap_set.hpp +2751 -0
- data/ext/boost/intrusive/trivial_value_traits.hpp +46 -0
- data/ext/boost/intrusive/unordered_set.hpp +2115 -0
- data/ext/boost/intrusive/unordered_set_hook.hpp +434 -0
- data/ext/boost/intrusive_ptr.hpp +18 -0
- data/ext/boost/math/common_factor_ct.hpp +180 -0
- data/ext/boost/math_fwd.hpp +108 -0
- data/ext/boost/move/detail/move_helpers.hpp +175 -0
- data/ext/boost/parameter.hpp +21 -0
- data/ext/boost/parameter/aux_/arg_list.hpp +459 -0
- data/ext/boost/parameter/aux_/cast.hpp +143 -0
- data/ext/boost/parameter/aux_/default.hpp +69 -0
- data/ext/boost/parameter/aux_/is_maybe.hpp +26 -0
- data/ext/boost/parameter/aux_/maybe.hpp +120 -0
- data/ext/boost/parameter/aux_/overloads.hpp +88 -0
- data/ext/boost/parameter/aux_/parameter_requirements.hpp +25 -0
- data/ext/boost/parameter/aux_/parenthesized_type.hpp +119 -0
- data/ext/boost/parameter/aux_/preprocessor/flatten.hpp +115 -0
- data/ext/boost/parameter/aux_/preprocessor/for_each.hpp +103 -0
- data/ext/boost/parameter/aux_/python/invoker.hpp +132 -0
- data/ext/boost/parameter/aux_/python/invoker_iterate.hpp +93 -0
- data/ext/boost/parameter/aux_/result_of0.hpp +36 -0
- data/ext/boost/parameter/aux_/set.hpp +67 -0
- data/ext/boost/parameter/aux_/tag.hpp +38 -0
- data/ext/boost/parameter/aux_/tagged_argument.hpp +188 -0
- data/ext/boost/parameter/aux_/template_keyword.hpp +47 -0
- data/ext/boost/parameter/aux_/unwrap_cv_reference.hpp +97 -0
- data/ext/boost/parameter/aux_/void.hpp +29 -0
- data/ext/boost/parameter/aux_/yesno.hpp +26 -0
- data/ext/boost/parameter/binding.hpp +106 -0
- data/ext/boost/parameter/config.hpp +14 -0
- data/ext/boost/parameter/keyword.hpp +152 -0
- data/ext/boost/parameter/macros.hpp +99 -0
- data/ext/boost/parameter/match.hpp +55 -0
- data/ext/boost/parameter/name.hpp +156 -0
- data/ext/boost/parameter/parameters.hpp +931 -0
- data/ext/boost/parameter/preprocessor.hpp +1178 -0
- data/ext/boost/parameter/python.hpp +735 -0
- data/ext/boost/parameter/value_type.hpp +108 -0
- data/ext/boost/pool/detail/for.m4 +107 -0
- data/ext/boost/pool/detail/guard.hpp +69 -0
- data/ext/boost/pool/detail/mutex.hpp +42 -0
- data/ext/boost/pool/detail/pool_construct.bat +24 -0
- data/ext/boost/pool/detail/pool_construct.ipp +852 -0
- data/ext/boost/pool/detail/pool_construct.m4 +84 -0
- data/ext/boost/pool/detail/pool_construct.sh +12 -0
- data/ext/boost/pool/detail/pool_construct_simple.bat +25 -0
- data/ext/boost/pool/detail/pool_construct_simple.ipp +43 -0
- data/ext/boost/pool/detail/pool_construct_simple.m4 +72 -0
- data/ext/boost/pool/detail/pool_construct_simple.sh +12 -0
- data/ext/boost/pool/object_pool.hpp +287 -0
- data/ext/boost/pool/pool.hpp +1024 -0
- data/ext/boost/pool/pool_alloc.hpp +488 -0
- data/ext/boost/pool/poolfwd.hpp +82 -0
- data/ext/boost/pool/simple_segregated_storage.hpp +377 -0
- data/ext/boost/pool/singleton_pool.hpp +251 -0
- data/ext/boost/preprocessor/arithmetic.hpp +25 -0
- data/ext/boost/preprocessor/arithmetic/detail/div_base.hpp +61 -0
- data/ext/boost/preprocessor/arithmetic/div.hpp +39 -0
- data/ext/boost/preprocessor/arithmetic/mod.hpp +39 -0
- data/ext/boost/preprocessor/arithmetic/mul.hpp +53 -0
- data/ext/boost/preprocessor/array.hpp +32 -0
- data/ext/boost/preprocessor/array/enum.hpp +33 -0
- data/ext/boost/preprocessor/array/insert.hpp +55 -0
- data/ext/boost/preprocessor/array/pop_back.hpp +37 -0
- data/ext/boost/preprocessor/array/pop_front.hpp +38 -0
- data/ext/boost/preprocessor/array/push_back.hpp +33 -0
- data/ext/boost/preprocessor/array/push_front.hpp +33 -0
- data/ext/boost/preprocessor/array/remove.hpp +54 -0
- data/ext/boost/preprocessor/array/replace.hpp +49 -0
- data/ext/boost/preprocessor/array/reverse.hpp +29 -0
- data/ext/boost/preprocessor/array/to_list.hpp +33 -0
- data/ext/boost/preprocessor/array/to_seq.hpp +33 -0
- data/ext/boost/preprocessor/array/to_tuple.hpp +22 -0
- data/ext/boost/preprocessor/assert_msg.hpp +17 -0
- data/ext/boost/preprocessor/comma.hpp +17 -0
- data/ext/boost/preprocessor/comparison.hpp +24 -0
- data/ext/boost/preprocessor/comparison/equal.hpp +34 -0
- data/ext/boost/preprocessor/comparison/greater.hpp +38 -0
- data/ext/boost/preprocessor/comparison/greater_equal.hpp +38 -0
- data/ext/boost/preprocessor/comparison/less.hpp +46 -0
- data/ext/boost/preprocessor/comparison/less_equal.hpp +39 -0
- data/ext/boost/preprocessor/comparison/not_equal.hpp +814 -0
- data/ext/boost/preprocessor/config/limits.hpp +30 -0
- data/ext/boost/preprocessor/control.hpp +22 -0
- data/ext/boost/preprocessor/control/deduce_d.hpp +22 -0
- data/ext/boost/preprocessor/control/detail/dmc/while.hpp +536 -0
- data/ext/boost/preprocessor/control/detail/edg/while.hpp +534 -0
- data/ext/boost/preprocessor/control/detail/msvc/while.hpp +277 -0
- data/ext/boost/preprocessor/control/expr_if.hpp +30 -0
- data/ext/boost/preprocessor/debug.hpp +18 -0
- data/ext/boost/preprocessor/debug/assert.hpp +44 -0
- data/ext/boost/preprocessor/debug/line.hpp +35 -0
- data/ext/boost/preprocessor/detail/dmc/auto_rec.hpp +286 -0
- data/ext/boost/preprocessor/detail/is_nullary.hpp +30 -0
- data/ext/boost/preprocessor/detail/is_unary.hpp +30 -0
- data/ext/boost/preprocessor/detail/null.hpp +17 -0
- data/ext/boost/preprocessor/detail/split.hpp +35 -0
- data/ext/boost/preprocessor/enum_params_with_defaults.hpp +17 -0
- data/ext/boost/preprocessor/enum_shifted.hpp +17 -0
- data/ext/boost/preprocessor/expand.hpp +17 -0
- data/ext/boost/preprocessor/expr_if.hpp +17 -0
- data/ext/boost/preprocessor/facilities.hpp +23 -0
- data/ext/boost/preprocessor/facilities/apply.hpp +34 -0
- data/ext/boost/preprocessor/facilities/expand.hpp +28 -0
- data/ext/boost/preprocessor/facilities/is_1.hpp +23 -0
- data/ext/boost/preprocessor/facilities/is_empty.hpp +43 -0
- data/ext/boost/preprocessor/facilities/is_empty_or_1.hpp +30 -0
- data/ext/boost/preprocessor/for.hpp +17 -0
- data/ext/boost/preprocessor/if.hpp +17 -0
- data/ext/boost/preprocessor/iteration.hpp +19 -0
- data/ext/boost/preprocessor/iteration/detail/bounds/lower3.hpp +99 -0
- data/ext/boost/preprocessor/iteration/detail/bounds/lower4.hpp +99 -0
- data/ext/boost/preprocessor/iteration/detail/bounds/lower5.hpp +99 -0
- data/ext/boost/preprocessor/iteration/detail/bounds/upper3.hpp +99 -0
- data/ext/boost/preprocessor/iteration/detail/bounds/upper4.hpp +99 -0
- data/ext/boost/preprocessor/iteration/detail/bounds/upper5.hpp +99 -0
- data/ext/boost/preprocessor/iteration/detail/finish.hpp +99 -0
- data/ext/boost/preprocessor/iteration/detail/iter/forward3.hpp +1338 -0
- data/ext/boost/preprocessor/iteration/detail/iter/forward4.hpp +1338 -0
- data/ext/boost/preprocessor/iteration/detail/iter/forward5.hpp +1338 -0
- data/ext/boost/preprocessor/iteration/detail/iter/reverse2.hpp +1296 -0
- data/ext/boost/preprocessor/iteration/detail/iter/reverse3.hpp +1296 -0
- data/ext/boost/preprocessor/iteration/detail/iter/reverse4.hpp +1296 -0
- data/ext/boost/preprocessor/iteration/detail/iter/reverse5.hpp +1296 -0
- data/ext/boost/preprocessor/iteration/detail/local.hpp +812 -0
- data/ext/boost/preprocessor/iteration/detail/rlocal.hpp +782 -0
- data/ext/boost/preprocessor/iteration/detail/self.hpp +21 -0
- data/ext/boost/preprocessor/iteration/detail/start.hpp +99 -0
- data/ext/boost/preprocessor/iteration/local.hpp +26 -0
- data/ext/boost/preprocessor/iteration/self.hpp +19 -0
- data/ext/boost/preprocessor/library.hpp +36 -0
- data/ext/boost/preprocessor/limits.hpp +17 -0
- data/ext/boost/preprocessor/list.hpp +37 -0
- data/ext/boost/preprocessor/list/at.hpp +39 -0
- data/ext/boost/preprocessor/list/cat.hpp +42 -0
- data/ext/boost/preprocessor/list/detail/dmc/fold_left.hpp +279 -0
- data/ext/boost/preprocessor/list/detail/edg/fold_left.hpp +536 -0
- data/ext/boost/preprocessor/list/detail/edg/fold_right.hpp +794 -0
- data/ext/boost/preprocessor/list/enum.hpp +41 -0
- data/ext/boost/preprocessor/list/filter.hpp +54 -0
- data/ext/boost/preprocessor/list/first_n.hpp +58 -0
- data/ext/boost/preprocessor/list/for_each.hpp +49 -0
- data/ext/boost/preprocessor/list/for_each_product.hpp +141 -0
- data/ext/boost/preprocessor/list/rest_n.hpp +55 -0
- data/ext/boost/preprocessor/list/size.hpp +58 -0
- data/ext/boost/preprocessor/list/to_array.hpp +123 -0
- data/ext/boost/preprocessor/list/to_seq.hpp +32 -0
- data/ext/boost/preprocessor/list/to_tuple.hpp +38 -0
- data/ext/boost/preprocessor/logical.hpp +29 -0
- data/ext/boost/preprocessor/logical/bitnor.hpp +38 -0
- data/ext/boost/preprocessor/logical/bitor.hpp +38 -0
- data/ext/boost/preprocessor/logical/bitxor.hpp +38 -0
- data/ext/boost/preprocessor/logical/nor.hpp +30 -0
- data/ext/boost/preprocessor/logical/not.hpp +30 -0
- data/ext/boost/preprocessor/logical/or.hpp +30 -0
- data/ext/boost/preprocessor/logical/xor.hpp +30 -0
- data/ext/boost/preprocessor/max.hpp +17 -0
- data/ext/boost/preprocessor/min.hpp +17 -0
- data/ext/boost/preprocessor/punctuation.hpp +20 -0
- data/ext/boost/preprocessor/punctuation/paren_if.hpp +38 -0
- data/ext/boost/preprocessor/repeat_3rd.hpp +17 -0
- data/ext/boost/preprocessor/repeat_from_to.hpp +17 -0
- data/ext/boost/preprocessor/repeat_from_to_2nd.hpp +17 -0
- data/ext/boost/preprocessor/repeat_from_to_3rd.hpp +17 -0
- data/ext/boost/preprocessor/repetition.hpp +32 -0
- data/ext/boost/preprocessor/repetition/deduce_r.hpp +22 -0
- data/ext/boost/preprocessor/repetition/deduce_z.hpp +22 -0
- data/ext/boost/preprocessor/repetition/detail/dmc/for.hpp +536 -0
- data/ext/boost/preprocessor/repetition/detail/edg/for.hpp +534 -0
- data/ext/boost/preprocessor/repetition/detail/msvc/for.hpp +277 -0
- data/ext/boost/preprocessor/repetition/enum_params_with_defaults.hpp +24 -0
- data/ext/boost/preprocessor/repetition/enum_shifted.hpp +68 -0
- data/ext/boost/preprocessor/repetition/enum_shifted_binary_params.hpp +51 -0
- data/ext/boost/preprocessor/repetition/enum_trailing.hpp +63 -0
- data/ext/boost/preprocessor/repetition/enum_trailing_binary_params.hpp +53 -0
- data/ext/boost/preprocessor/selection.hpp +18 -0
- data/ext/boost/preprocessor/selection/max.hpp +39 -0
- data/ext/boost/preprocessor/selection/min.hpp +39 -0
- data/ext/boost/preprocessor/seq.hpp +43 -0
- data/ext/boost/preprocessor/seq/cat.hpp +49 -0
- data/ext/boost/preprocessor/seq/detail/binary_transform.hpp +40 -0
- data/ext/boost/preprocessor/seq/detail/split.hpp +284 -0
- data/ext/boost/preprocessor/seq/filter.hpp +54 -0
- data/ext/boost/preprocessor/seq/first_n.hpp +30 -0
- data/ext/boost/preprocessor/seq/fold_left.hpp +1070 -0
- data/ext/boost/preprocessor/seq/fold_right.hpp +288 -0
- data/ext/boost/preprocessor/seq/for_each.hpp +60 -0
- data/ext/boost/preprocessor/seq/for_each_product.hpp +126 -0
- data/ext/boost/preprocessor/seq/insert.hpp +28 -0
- data/ext/boost/preprocessor/seq/pop_back.hpp +29 -0
- data/ext/boost/preprocessor/seq/pop_front.hpp +27 -0
- data/ext/boost/preprocessor/seq/push_back.hpp +19 -0
- data/ext/boost/preprocessor/seq/push_front.hpp +19 -0
- data/ext/boost/preprocessor/seq/remove.hpp +29 -0
- data/ext/boost/preprocessor/seq/replace.hpp +29 -0
- data/ext/boost/preprocessor/seq/rest_n.hpp +30 -0
- data/ext/boost/preprocessor/seq/reverse.hpp +39 -0
- data/ext/boost/preprocessor/seq/subseq.hpp +28 -0
- data/ext/boost/preprocessor/seq/to_array.hpp +28 -0
- data/ext/boost/preprocessor/seq/to_list.hpp +29 -0
- data/ext/boost/preprocessor/seq/to_tuple.hpp +27 -0
- data/ext/boost/preprocessor/seq/transform.hpp +48 -0
- data/ext/boost/preprocessor/slot.hpp +17 -0
- data/ext/boost/preprocessor/slot/counter.hpp +25 -0
- data/ext/boost/preprocessor/slot/detail/counter.hpp +269 -0
- data/ext/boost/preprocessor/slot/detail/slot1.hpp +267 -0
- data/ext/boost/preprocessor/slot/detail/slot2.hpp +267 -0
- data/ext/boost/preprocessor/slot/detail/slot3.hpp +267 -0
- data/ext/boost/preprocessor/slot/detail/slot4.hpp +267 -0
- data/ext/boost/preprocessor/slot/detail/slot5.hpp +267 -0
- data/ext/boost/preprocessor/tuple.hpp +28 -0
- data/ext/boost/preprocessor/tuple/enum.hpp +22 -0
- data/ext/boost/preprocessor/tuple/reverse.hpp +114 -0
- data/ext/boost/preprocessor/tuple/size.hpp +28 -0
- data/ext/boost/preprocessor/tuple/to_array.hpp +37 -0
- data/ext/boost/preprocessor/tuple/to_seq.hpp +114 -0
- data/ext/boost/preprocessor/variadic.hpp +23 -0
- data/ext/boost/preprocessor/variadic/to_array.hpp +32 -0
- data/ext/boost/preprocessor/variadic/to_list.hpp +25 -0
- data/ext/boost/preprocessor/variadic/to_seq.hpp +25 -0
- data/ext/boost/preprocessor/variadic/to_tuple.hpp +24 -0
- data/ext/boost/preprocessor/while.hpp +17 -0
- data/ext/boost/preprocessor/wstringize.hpp +29 -0
- data/ext/boost/smart_ptr/intrusive_ptr.hpp +324 -0
- data/ext/common/AccountsDatabase.h +3 -4
- data/ext/common/AgentsStarter.cpp +12 -15
- data/ext/common/AgentsStarter.h +54 -120
- data/ext/common/ApplicationPool2/AppTypes.cpp +12 -5
- data/ext/common/ApplicationPool2/AppTypes.h +21 -14
- data/ext/common/ApplicationPool2/Common.h +36 -19
- data/ext/common/ApplicationPool2/DirectSpawner.h +15 -16
- data/ext/common/ApplicationPool2/DummySpawner.h +9 -8
- data/ext/common/ApplicationPool2/ErrorRenderer.h +1 -1
- data/ext/common/ApplicationPool2/Group.h +304 -171
- data/ext/common/ApplicationPool2/Implementation.cpp +234 -125
- data/ext/common/ApplicationPool2/Options.h +50 -62
- data/ext/common/ApplicationPool2/Pool.h +285 -189
- data/ext/common/ApplicationPool2/Process.h +126 -115
- data/ext/common/ApplicationPool2/Session.h +70 -30
- data/ext/common/ApplicationPool2/SmartSpawner.h +19 -18
- data/ext/common/ApplicationPool2/Socket.h +57 -43
- data/ext/common/ApplicationPool2/SpawnObject.h +83 -0
- data/ext/common/ApplicationPool2/Spawner.h +59 -38
- data/ext/common/ApplicationPool2/SpawnerFactory.h +8 -14
- data/ext/common/ApplicationPool2/SuperGroup.h +69 -40
- data/ext/common/BackgroundEventLoop.cpp +48 -1
- data/ext/common/BackgroundEventLoop.h +3 -1
- data/ext/common/Constants.h +30 -8
- data/ext/common/DataStructures/HashedStaticString.h +103 -0
- data/ext/common/DataStructures/LString.h +396 -0
- data/ext/common/DataStructures/StringKeyTable.h +588 -0
- data/ext/common/EventedMessageServer.h +1 -0
- data/ext/common/FileDescriptor.h +5 -0
- data/ext/common/InstanceDirectory.h +240 -0
- data/ext/common/Logging.cpp +38 -13
- data/ext/common/Logging.h +53 -22
- data/ext/common/MemoryKit/mbuf.cpp +413 -0
- data/ext/common/MemoryKit/mbuf.h +266 -0
- data/ext/common/MemoryKit/palloc.cpp +337 -0
- data/ext/common/MemoryKit/palloc.h +121 -0
- data/ext/common/ResourceLocator.h +62 -6
- data/ext/common/SafeLibev.h +4 -4
- data/ext/common/ServerKit/AcceptLoadBalancer.h +275 -0
- data/ext/common/ServerKit/Channel.h +747 -0
- data/ext/common/ServerKit/Client.h +166 -0
- data/ext/common/ServerKit/ClientRef.h +130 -0
- data/ext/common/ServerKit/Context.h +129 -0
- data/ext/common/ServerKit/Errors.h +103 -0
- data/ext/common/ServerKit/FdSinkChannel.h +206 -0
- data/ext/common/ServerKit/FdSourceChannel.h +230 -0
- data/ext/common/ServerKit/FileBufferedChannel.h +1399 -0
- data/ext/common/ServerKit/FileBufferedFdSinkChannel.h +228 -0
- data/ext/common/ServerKit/HeaderTable.h +472 -0
- data/ext/common/ServerKit/Hooks.h +79 -0
- data/ext/common/ServerKit/HttpChunkedBodyParser.h +289 -0
- data/ext/common/ServerKit/HttpChunkedBodyParserState.h +70 -0
- data/ext/common/ServerKit/HttpClient.h +94 -0
- data/ext/common/ServerKit/HttpHeaderParser.h +477 -0
- data/ext/common/ServerKit/HttpHeaderParserState.h +60 -0
- data/ext/common/ServerKit/HttpRequest.h +276 -0
- data/ext/common/ServerKit/HttpRequestRef.h +130 -0
- data/ext/common/ServerKit/HttpServer.h +1152 -0
- data/ext/common/ServerKit/Implementation.cpp +47 -0
- data/ext/common/ServerKit/Server.h +1040 -0
- data/ext/common/ServerKit/http_parser.cpp +2259 -0
- data/ext/common/ServerKit/http_parser.h +330 -0
- data/ext/common/StaticString.h +8 -0
- data/ext/common/Utils.cpp +14 -12
- data/ext/common/Utils.h +9 -103
- data/ext/common/Utils/BufferedIO.h +1 -0
- data/ext/common/Utils/CachedFileStat.hpp +1 -7
- data/ext/common/Utils/DateParsing.h +379 -0
- data/ext/common/Utils/FileChangeChecker.h +3 -9
- data/ext/common/Utils/Hasher.cpp +52 -0
- data/ext/common/Utils/Hasher.h +58 -0
- data/ext/common/Utils/IOUtils.cpp +62 -62
- data/ext/common/Utils/JsonUtils.h +21 -0
- data/ext/common/Utils/OptionParsing.h +75 -0
- data/ext/common/Utils/StrIntUtils.cpp +112 -19
- data/ext/common/Utils/StrIntUtils.h +52 -12
- data/ext/common/Utils/StrIntUtilsNoStrictAliasing.cpp +174 -0
- data/ext/common/Utils/VariantMap.h +18 -7
- data/ext/common/Utils/modp_b64.cpp +290 -0
- data/ext/common/Utils/modp_b64.h +241 -0
- data/ext/common/Utils/modp_b64_data.h +479 -0
- data/ext/common/Utils/sysqueue.h +811 -0
- data/ext/common/agents/Base.cpp +71 -98
- data/ext/common/agents/Base.h +11 -3
- data/ext/common/agents/HelperAgent/AdminServer.h +690 -0
- data/ext/common/agents/HelperAgent/Main.cpp +899 -487
- data/ext/common/agents/HelperAgent/OptionParser.h +311 -0
- data/ext/common/agents/HelperAgent/RequestHandler.h +315 -2548
- data/ext/common/agents/HelperAgent/RequestHandler/AppResponse.h +225 -0
- data/ext/common/agents/HelperAgent/RequestHandler/BufferBody.cpp +93 -0
- data/ext/common/agents/HelperAgent/RequestHandler/CheckoutSession.cpp +346 -0
- data/ext/common/agents/HelperAgent/RequestHandler/Client.h +54 -0
- data/ext/common/agents/HelperAgent/RequestHandler/ForwardResponse.cpp +846 -0
- data/ext/common/agents/HelperAgent/RequestHandler/Hooks.cpp +231 -0
- data/ext/common/agents/HelperAgent/RequestHandler/InitRequest.cpp +434 -0
- data/ext/common/agents/HelperAgent/RequestHandler/Request.h +149 -0
- data/ext/common/agents/HelperAgent/RequestHandler/SendRequest.cpp +887 -0
- data/ext/common/agents/HelperAgent/RequestHandler/TurboCaching.h +293 -0
- data/ext/common/agents/HelperAgent/RequestHandler/Utils.cpp +301 -0
- data/ext/common/agents/HelperAgent/ResponseCache.h +624 -0
- data/ext/common/agents/HelperAgent/SystemMetricsTool.cpp +21 -23
- data/ext/common/agents/LoggingAgent/AdminServer.h +369 -0
- data/ext/common/agents/LoggingAgent/LoggingServer.h +1 -0
- data/ext/common/agents/LoggingAgent/Main.cpp +422 -215
- data/ext/common/agents/LoggingAgent/OptionParser.h +167 -0
- data/ext/common/agents/LoggingAgent/RemoteSender.h +3 -3
- data/ext/common/agents/Main.cpp +107 -0
- data/ext/common/agents/SpawnPreparer/Main.cpp +207 -0
- data/ext/common/agents/TempDirToucher/Main.cpp +429 -0
- data/ext/common/agents/Watchdog/AdminServer.h +390 -0
- data/ext/common/agents/Watchdog/AgentWatcher.cpp +7 -5
- data/ext/common/agents/Watchdog/HelperAgentWatcher.cpp +18 -39
- data/ext/common/agents/Watchdog/InstanceDirToucher.cpp +116 -0
- data/ext/common/agents/Watchdog/LoggingAgentWatcher.cpp +13 -17
- data/ext/common/agents/Watchdog/Main.cpp +743 -202
- data/ext/libeio/eio.c +17 -0
- data/ext/libeio/eio.h +2 -0
- data/ext/nginx/CacheLocationConfig.c +177 -198
- data/ext/nginx/CacheLocationConfig.c.erb +35 -22
- data/ext/nginx/Configuration.c +402 -236
- data/ext/nginx/Configuration.h +12 -5
- data/ext/nginx/ConfigurationCommands.c +35 -15
- data/ext/nginx/ConfigurationCommands.c.erb +4 -4
- data/ext/nginx/ConfigurationFields.h +9 -5
- data/ext/nginx/ConfigurationFields.h.erb +3 -1
- data/ext/nginx/ContentHandler.c +393 -362
- data/ext/nginx/CreateLocationConfig.c +8 -4
- data/ext/nginx/CreateLocationConfig.c.erb +8 -3
- data/ext/nginx/MergeLocationConfig.c +36 -6
- data/ext/nginx/MergeLocationConfig.c.erb +42 -1
- data/ext/nginx/ngx_http_passenger_module.c +28 -15
- data/ext/oxt/detail/backtrace_disabled.hpp +2 -1
- data/ext/oxt/detail/backtrace_enabled.hpp +15 -2
- data/ext/oxt/implementation.cpp +92 -20
- data/ext/oxt/thread.hpp +5 -0
- data/ext/ruby/extconf.rb +3 -6
- data/ext/ruby/passenger_native_support.c +13 -40
- data/helper-scripts/download_binaries/extconf.rb +4 -4
- data/helper-scripts/meteor-loader.rb +12 -112
- data/helper-scripts/node-loader.js +3 -91
- data/helper-scripts/rack-loader.rb +13 -14
- data/helper-scripts/rack-preloader.rb +16 -17
- data/helper-scripts/wsgi-loader.py +11 -7
- data/lib/phusion_passenger.rb +100 -79
- data/lib/phusion_passenger/abstract_installer.rb +28 -3
- data/lib/phusion_passenger/admin_tools.rb +3 -3
- data/lib/phusion_passenger/admin_tools/instance.rb +207 -0
- data/lib/phusion_passenger/admin_tools/instance_registry.rb +98 -0
- data/lib/phusion_passenger/apache2/config_options.rb +72 -22
- data/lib/phusion_passenger/common_library.rb +79 -14
- data/lib/phusion_passenger/config/about_command.rb +17 -23
- data/lib/phusion_passenger/config/admin_command_command.rb +175 -0
- data/lib/phusion_passenger/config/agent_compiler.rb +170 -0
- data/lib/phusion_passenger/config/command.rb +1 -4
- data/lib/phusion_passenger/config/compile_agent_command.rb +102 -0
- data/lib/phusion_passenger/config/compile_nginx_engine_command.rb +112 -0
- data/lib/phusion_passenger/config/detach_process_command.rb +32 -10
- data/lib/phusion_passenger/config/download_agent_command.rb +285 -0
- data/lib/phusion_passenger/config/download_nginx_engine_command.rb +281 -0
- data/lib/phusion_passenger/config/install_agent_command.rb +174 -0
- data/lib/phusion_passenger/config/install_standalone_runtime_command.rb +231 -0
- data/lib/phusion_passenger/config/installation_utils.rb +241 -0
- data/lib/phusion_passenger/config/list_instances_command.rb +13 -25
- data/lib/phusion_passenger/config/main.rb +43 -14
- data/lib/phusion_passenger/config/nginx_engine_compiler.rb +337 -0
- data/lib/phusion_passenger/config/reopen_logs_command.rb +110 -0
- data/lib/phusion_passenger/config/restart_app_command.rb +61 -14
- data/lib/phusion_passenger/config/system_metrics_command.rb +2 -1
- data/lib/phusion_passenger/config/utils.rb +64 -39
- data/lib/phusion_passenger/config/validate_install_command.rb +2 -2
- data/lib/phusion_passenger/constants.rb +27 -6
- data/lib/phusion_passenger/debug_logging.rb +32 -15
- data/lib/phusion_passenger/loader_shared_helpers.rb +2 -5
- data/lib/phusion_passenger/message_client.rb +21 -22
- data/lib/phusion_passenger/native_support.rb +26 -31
- data/lib/phusion_passenger/nginx/config_options.rb +32 -19
- data/lib/phusion_passenger/packaging.rb +7 -3
- data/lib/phusion_passenger/platform_info/cxx_portability.rb +1 -2
- data/lib/phusion_passenger/platform_info/depcheck_specs/libs.rb +3 -4
- data/lib/phusion_passenger/platform_info/operating_system.rb +6 -6
- data/lib/phusion_passenger/preloader_shared_helpers.rb +2 -2
- data/lib/phusion_passenger/rack/out_of_band_gc.rb +2 -2
- data/lib/phusion_passenger/rack/thread_handler_extension.rb +168 -65
- data/lib/phusion_passenger/request_handler.rb +47 -82
- data/lib/phusion_passenger/request_handler/thread_handler.rb +46 -10
- data/lib/phusion_passenger/ruby_core_enhancements.rb +25 -77
- data/lib/phusion_passenger/ruby_core_io_enhancements.rb +108 -0
- data/lib/phusion_passenger/standalone/app_finder.rb +39 -59
- data/lib/phusion_passenger/standalone/command.rb +27 -275
- data/lib/phusion_passenger/standalone/command2.rb +292 -0
- data/lib/phusion_passenger/standalone/config_utils.rb +87 -0
- data/lib/phusion_passenger/standalone/control_utils.rb +88 -0
- data/lib/phusion_passenger/standalone/main.rb +69 -71
- data/lib/phusion_passenger/standalone/start2_command.rb +799 -0
- data/lib/phusion_passenger/standalone/start_command.rb +406 -467
- data/lib/phusion_passenger/standalone/start_command/builtin_engine.rb +167 -0
- data/lib/phusion_passenger/standalone/start_command/nginx_engine.rb +165 -0
- data/lib/phusion_passenger/standalone/status_command.rb +64 -23
- data/lib/phusion_passenger/standalone/stop_command.rb +69 -32
- data/lib/phusion_passenger/standalone/version_command.rb +1 -5
- data/lib/phusion_passenger/utils.rb +0 -4
- data/lib/phusion_passenger/utils/json.rb +70 -4
- data/lib/phusion_passenger/utils/progress_bar.rb +56 -0
- data/lib/phusion_passenger/utils/tee_input.rb +3 -3
- data/lib/phusion_passenger/utils/unseekable_socket.rb +30 -0
- data/packaging/rpm/nginx_spec/nginx.spec.template +4 -3
- data/packaging/rpm/passenger_spec/passenger.spec.template +6 -10
- data/packaging/rpm/setup-system +2 -1
- data/resources/oss-binaries.phusionpassenger.com.crt +208 -0
- data/resources/templates/config/agent_compiler/confirm_enable_optimizations.txt.erb +5 -0
- data/resources/templates/config/installation_utils/cannot_create_user_support_binaries_dir.txt.erb +15 -0
- data/resources/templates/config/installation_utils/download_tool_missing.txt.erb +7 -0
- data/resources/templates/config/installation_utils/passenger_not_installed_as_root.txt.erb +12 -0
- data/resources/templates/config/installation_utils/support_binaries_dir_not_writable_despite_running_as_root.txt.erb +13 -0
- data/resources/templates/config/installation_utils/unexpected_filesystem_problem.txt.erb +16 -0
- data/{packaging/debian/debian_specs/passenger/patches/series → resources/templates/config/installation_utils/user_support_binaries_dir_not_writable.txt.erb} +0 -0
- data/resources/templates/nginx/nginx_module_sources_not_available.txt.erb +2 -2
- data/resources/templates/standalone/config.erb +14 -16
- data/resources/templates/standalone/possible_solutions_for_download_and_extraction_problems.txt.erb +1 -1
- data/test/.rspec +1 -0
- data/test/cxx/ApplicationPool2/DirectSpawnerTest.cpp +20 -17
- data/test/cxx/ApplicationPool2/OptionsTest.cpp +0 -14
- data/test/cxx/ApplicationPool2/PoolTest.cpp +113 -90
- data/test/cxx/ApplicationPool2/ProcessTest.cpp +18 -27
- data/test/cxx/ApplicationPool2/SmartSpawnerTest.cpp +51 -53
- data/test/cxx/ApplicationPool2/SpawnerTestCases.cpp +55 -57
- data/test/cxx/BufferedIOTest.cpp +40 -40
- data/test/cxx/CxxTestMain.cpp +4 -22
- data/test/cxx/DataStructures/LStringTest.cpp +275 -0
- data/test/cxx/DataStructures/StringKeyTableTest.cpp +199 -0
- data/test/cxx/MemoryKit/MbufTest.cpp +213 -0
- data/test/cxx/MessageServerTest.cpp +62 -55
- data/test/cxx/RequestHandlerTest.cpp +26 -27
- data/test/cxx/ServerKit/ChannelTest.cpp +1467 -0
- data/test/cxx/ServerKit/FileBufferedChannelTest.cpp +817 -0
- data/test/cxx/ServerKit/HeaderTableTest.cpp +171 -0
- data/test/cxx/ServerKit/HttpServerTest.cpp +1503 -0
- data/test/cxx/ServerKit/ServerTest.cpp +408 -0
- data/test/cxx/TestSupport.cpp +51 -15
- data/test/cxx/TestSupport.h +31 -21
- data/test/cxx/UnionStationTest.cpp +121 -122
- data/test/cxx/UtilsTest.cpp +9 -33
- data/test/integration_tests/apache2_tests.rb +65 -27
- data/test/integration_tests/downloaded_binaries_tests.rb +30 -6
- data/test/integration_tests/native_packaging_spec.rb +32 -17
- data/test/integration_tests/nginx_tests.rb +28 -10
- data/test/integration_tests/shared/example_webapp_tests.rb +40 -27
- data/test/integration_tests/standalone_tests.rb +232 -169
- data/test/ruby/debug_logging_spec.rb +44 -40
- data/test/ruby/rails3.0/preloader_spec.rb +1 -1
- data/test/ruby/rails3.1/preloader_spec.rb +1 -1
- data/test/ruby/rails3.2/preloader_spec.rb +1 -1
- data/test/ruby/rails4.0/preloader_spec.rb +1 -1
- data/test/ruby/rails4.1/preloader_spec.rb +1 -1
- data/test/ruby/request_handler_spec.rb +62 -24
- data/test/ruby/shared/loader_sharedspec.rb +10 -9
- data/test/ruby/shared/rails/union_station_extensions_sharedspec.rb +23 -22
- data/test/ruby/spec_helper.rb +2 -11
- data/test/ruby/standalone/runtime_installer_spec.rb +15 -13
- data/test/ruby/union_station_spec.rb +45 -40
- data/test/ruby/utils/tee_input_spec.rb +5 -5
- data/test/ruby/utils_spec.rb +3 -39
- data/test/stub/apache2/httpd.conf.erb +5 -2
- data/test/stub/nginx/nginx.conf.erb +3 -1
- data/test/support/apache2_controller.rb +25 -25
- data/test/support/nginx_controller.rb +14 -14
- data/test/support/test_helper.rb +74 -75
- metadata +439 -643
- metadata.gz.asc +7 -7
- data/ext/common/MultiLibeio.cpp +0 -204
- data/ext/common/MultiLibeio.h +0 -67
- data/ext/common/ServerInstanceDir.h +0 -402
- data/ext/common/Utils/Base64.cpp +0 -143
- data/ext/common/Utils/Base64.h +0 -83
- data/ext/common/Utils/HttpHeaderBufferer.h +0 -184
- data/ext/common/Utils/PriorityQueue.h +0 -54
- data/ext/common/Utils/StreamBoyerMooreHorspool.h +0 -512
- data/ext/common/Utils/fib.c +0 -699
- data/ext/common/Utils/fib.h +0 -101
- data/ext/common/Utils/fibpriv.h +0 -67
- data/ext/common/agents/EnvPrinter.c +0 -16
- data/ext/common/agents/HelperAgent/AgentOptions.h +0 -109
- data/ext/common/agents/HelperAgent/FileBackedPipe.h +0 -732
- data/ext/common/agents/HelperAgent/RequestHandler.cpp +0 -294
- data/ext/common/agents/HelperAgent/ScgiRequestParser.h +0 -457
- data/ext/common/agents/LoggingAgent/AdminController.h +0 -96
- data/ext/common/agents/SpawnPreparer.cpp +0 -206
- data/ext/common/agents/TempDirToucher.c +0 -383
- data/ext/common/agents/Watchdog/ServerInstanceDirToucher.cpp +0 -116
- data/helper-scripts/classic-rails-loader.rb +0 -166
- data/helper-scripts/classic-rails-preloader.rb +0 -193
- data/lib/phusion_passenger/admin_tools/server_instance.rb +0 -339
- data/lib/phusion_passenger/classic_rails/cgi_fixed.rb +0 -68
- data/lib/phusion_passenger/classic_rails/thread_handler_extension.rb +0 -40
- data/lib/phusion_passenger/platform_info/openssl.rb +0 -61
- data/lib/phusion_passenger/standalone/config_file.rb +0 -119
- data/lib/phusion_passenger/standalone/help_command.rb +0 -57
- data/lib/phusion_passenger/standalone/runtime_installer.rb +0 -712
- data/lib/phusion_passenger/standalone/runtime_locator.rb +0 -170
- data/lib/phusion_passenger/standalone/utils.rb +0 -58
- data/lib/phusion_passenger/utils/tmpdir.rb +0 -69
- data/packaging/debian/LICENSE.md +0 -19
- data/packaging/debian/README.md +0 -320
- data/packaging/debian/Vagrantfile +0 -25
- data/packaging/debian/build +0 -210
- data/packaging/debian/debian_specs/nginx/changelog +0 -1989
- data/packaging/debian/debian_specs/nginx/compat.erb +0 -5
- data/packaging/debian/debian_specs/nginx/conf/fastcgi.conf +0 -25
- data/packaging/debian/debian_specs/nginx/conf/fastcgi_params +0 -24
- data/packaging/debian/debian_specs/nginx/conf/koi-utf +0 -109
- data/packaging/debian/debian_specs/nginx/conf/koi-win +0 -103
- data/packaging/debian/debian_specs/nginx/conf/mime.types +0 -89
- data/packaging/debian/debian_specs/nginx/conf/nginx.conf.erb +0 -97
- data/packaging/debian/debian_specs/nginx/conf/proxy_params +0 -4
- data/packaging/debian/debian_specs/nginx/conf/scgi_params +0 -16
- data/packaging/debian/debian_specs/nginx/conf/sites-available/default.erb +0 -93
- data/packaging/debian/debian_specs/nginx/conf/snippets/fastcgi-php.conf +0 -13
- data/packaging/debian/debian_specs/nginx/conf/snippets/snakeoil.conf +0 -5
- data/packaging/debian/debian_specs/nginx/conf/uwsgi_params +0 -16
- data/packaging/debian/debian_specs/nginx/conf/win-utf +0 -125
- data/packaging/debian/debian_specs/nginx/control.erb +0 -226
- data/packaging/debian/debian_specs/nginx/copyright +0 -196
- data/packaging/debian/debian_specs/nginx/debian-full.lintian-overrides +0 -1
- data/packaging/debian/debian_specs/nginx/gbp.conf +0 -2
- data/packaging/debian/debian_specs/nginx/help/docs/fcgiwrap +0 -14
- data/packaging/debian/debian_specs/nginx/help/docs/php +0 -119
- data/packaging/debian/debian_specs/nginx/help/docs/support-irc +0 -28
- data/packaging/debian/debian_specs/nginx/help/docs/upstream +0 -51
- data/packaging/debian/debian_specs/nginx/help/examples/drupal +0 -114
- data/packaging/debian/debian_specs/nginx/help/examples/http +0 -59
- data/packaging/debian/debian_specs/nginx/help/examples/mail +0 -30
- data/packaging/debian/debian_specs/nginx/help/examples/mailman +0 -59
- data/packaging/debian/debian_specs/nginx/help/examples/nginx.conf +0 -34
- data/packaging/debian/debian_specs/nginx/help/examples/nginx_modsite +0 -162
- data/packaging/debian/debian_specs/nginx/help/examples/virtual_hosts +0 -155
- data/packaging/debian/debian_specs/nginx/help/examples/wordpress +0 -74
- data/packaging/debian/debian_specs/nginx/helpers.rb +0 -41
- data/packaging/debian/debian_specs/nginx/index-debian.html.in +0 -32
- data/packaging/debian/debian_specs/nginx/index-ubuntu.html.in +0 -32
- data/packaging/debian/debian_specs/nginx/index.html.erb +0 -10
- data/packaging/debian/debian_specs/nginx/modules/README.Modules-versions +0 -65
- data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/README.markdown +0 -510
- data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/config +0 -5
- data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/doc/HttpHeadersMoreModule.wiki +0 -395
- data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ddebug.h +0 -119
- data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_filter_module.c +0 -348
- data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_filter_module.h +0 -80
- data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_headers_in.c +0 -826
- data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_headers_in.h +0 -26
- data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_headers_out.c +0 -716
- data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_headers_out.h +0 -26
- data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_util.c +0 -380
- data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_util.h +0 -52
- data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/util/build.sh +0 -32
- data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/valgrind.suppress +0 -215
- data/packaging/debian/debian_specs/nginx/modules/nginx-auth-pam/ChangeLog +0 -35
- data/packaging/debian/debian_specs/nginx/modules/nginx-auth-pam/LICENSE +0 -25
- data/packaging/debian/debian_specs/nginx/modules/nginx-auth-pam/README.md +0 -93
- data/packaging/debian/debian_specs/nginx/modules/nginx-auth-pam/config +0 -4
- data/packaging/debian/debian_specs/nginx/modules/nginx-auth-pam/ngx_http_auth_pam_module.c +0 -462
- data/packaging/debian/debian_specs/nginx/modules/nginx-cache-purge/CHANGES +0 -66
- data/packaging/debian/debian_specs/nginx/modules/nginx-cache-purge/LICENSE +0 -26
- data/packaging/debian/debian_specs/nginx/modules/nginx-cache-purge/README.md +0 -171
- data/packaging/debian/debian_specs/nginx/modules/nginx-cache-purge/TODO.md +0 -7
- data/packaging/debian/debian_specs/nginx/modules/nginx-cache-purge/config +0 -21
- data/packaging/debian/debian_specs/nginx/modules/nginx-cache-purge/ngx_cache_purge_module.c +0 -1803
- data/packaging/debian/debian_specs/nginx/modules/nginx-dav-ext-module/README +0 -29
- data/packaging/debian/debian_specs/nginx/modules/nginx-dav-ext-module/config +0 -9
- data/packaging/debian/debian_specs/nginx/modules/nginx-dav-ext-module/ngx_http_dav_ext_module.c +0 -824
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/README +0 -139
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/README_AUTO_LIB +0 -395
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/TODO +0 -1
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/actions/array +0 -10
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/actions/palloc +0 -8
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/build +0 -597
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/action_replacements +0 -5
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/action_types +0 -12
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/conf_args +0 -22
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/conf_locs +0 -25
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/conf_macros +0 -35
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/contexts +0 -22
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/header_files +0 -3
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/headers +0 -4
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/module_dependencies +0 -5
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/modules_optional +0 -15
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/prefixes +0 -2
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/src/array.h +0 -7
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/src/conf_cmd_basic.h +0 -43
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/src/conf_merge.h +0 -78
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/src/palloc.h +0 -6
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/text/autogen +0 -12
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/config +0 -49
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/docs/core/action_macros +0 -63
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/docs/core/conf_cmds +0 -62
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/docs/modules/set_var +0 -124
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/docs/patches/more_logging_info +0 -48
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/docs/upstream/list +0 -45
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/examples/README +0 -12
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/examples/http/set_var/config +0 -4
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/examples/http/set_var/ngx_http_set_var_examples_module.c +0 -136
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/ngx_auto_lib_core +0 -797
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/notes/CHANGES +0 -17
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/notes/LICENSE +0 -24
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_array.h +0 -113
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_conf_cmd_basic.h +0 -2203
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_conf_cmd_extra.h +0 -5423
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_conf_merge.h +0 -227
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_config.c +0 -72
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_config.h +0 -98
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_includes.h +0 -66
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_palloc.h +0 -112
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/patches/auto_config +0 -16
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/patches/expose_rewrite_functions +0 -291
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/patches/rewrite_phase_handler +0 -19
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/hash/md5.h +0 -117
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/hash/murmurhash2.c +0 -77
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/hash/sha.h +0 -200
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk.c +0 -155
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk.h +0 -58
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_buf.c +0 -43
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_buf.h +0 -5
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_complex_path.c +0 -129
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_complex_path.h +0 -30
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_complex_value.c +0 -192
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_complex_value.h +0 -21
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_conf_file.c +0 -396
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_conf_file.h +0 -44
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_debug.c +0 -72
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_debug.h +0 -171
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_encoding.c +0 -57
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_encoding.h +0 -12
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_hash.c +0 -82
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_hash.h +0 -45
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_http.c +0 -138
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_http.h +0 -3
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_http_headers.h +0 -35
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_log.c +0 -3
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_log.h +0 -165
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_parse.h +0 -67
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_path.c +0 -583
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_path.h +0 -22
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_process.c +0 -20
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_process.h +0 -12
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_regex.c +0 -215
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_regex.h +0 -7
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_rewrite.c +0 -103
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_rewrite.h +0 -26
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_set_var.c +0 -602
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_set_var.h +0 -44
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_string.c +0 -434
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_string.h +0 -37
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_string_util.h +0 -14
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_upstream_list.c +0 -205
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_upstream_list.h +0 -27
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_uri.c +0 -45
- data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_uri.h +0 -6
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/LICENSE +0 -25
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/README.markdown +0 -1850
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/config +0 -5
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/doc/HttpEchoModule.wiki +0 -1558
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ddebug.h +0 -109
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_echo.c +0 -344
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_echo.h +0 -25
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_filter.c +0 -282
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_filter.h +0 -15
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_foreach.c +0 -183
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_foreach.h +0 -16
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_handler.c +0 -429
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_handler.h +0 -18
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_location.c +0 -178
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_location.h +0 -13
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_module.c +0 -667
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_module.h +0 -137
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_request_info.c +0 -452
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_request_info.h +0 -31
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_sleep.c +0 -208
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_sleep.h +0 -16
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_subrequest.c +0 -788
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_subrequest.h +0 -19
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_timer.c +0 -96
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_timer.h +0 -13
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_util.c +0 -298
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_util.h +0 -58
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_var.c +0 -110
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_var.h +0 -9
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/util/build.sh +0 -45
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/util/releng +0 -8
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/util/wiki2pod.pl +0 -131
- data/packaging/debian/debian_specs/nginx/modules/nginx-echo/valgrind.suppress +0 -38
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/LICENCE +0 -24
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/README +0 -206
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/changelog.txt +0 -54
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/config +0 -26
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/protocol.txt +0 -191
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/ngx_http_push_defs.c +0 -59
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/ngx_http_push_defs.h +0 -73
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/ngx_http_push_module.c +0 -783
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/ngx_http_push_module.h +0 -31
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/ngx_http_push_module_setup.c +0 -361
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/ngx_http_push_types.h +0 -120
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/memory/store.c +0 -1180
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/memory/store.h +0 -1
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/ngx_http_push_module_ipc.c +0 -146
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/ngx_http_push_module_ipc.h +0 -5
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/ngx_http_push_store.h +0 -51
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/ngx_rwlock.c +0 -178
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/ngx_rwlock.h +0 -5
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/rbtree_util.c +0 -246
- data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/rbtree_util.h +0 -9
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/Changes +0 -51
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/README.markdown +0 -6954
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/config +0 -363
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/doc/HttpLuaModule.wiki +0 -5898
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/dtrace/ngx_lua_provider.d +0 -61
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/misc/recv-until-pm/Makefile +0 -3
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/misc/recv-until-pm/lib/RecvUntil.pm +0 -138
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/misc/recv-until-pm/t/sanity.t +0 -140
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/api/ngx_http_lua_api.h +0 -52
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ddebug.h +0 -82
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_accessby.c +0 -377
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_accessby.h +0 -22
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_api.c +0 -77
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_args.c +0 -537
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_args.h +0 -20
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_bodyfilterby.c +0 -632
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_bodyfilterby.h +0 -31
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_cache.c +0 -296
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_cache.h +0 -24
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_capturefilter.c +0 -175
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_capturefilter.h +0 -20
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_clfactory.c +0 -887
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_clfactory.h +0 -22
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_common.h +0 -478
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_config.c +0 -67
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_config.h +0 -19
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_consts.c +0 -148
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_consts.h +0 -20
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_contentby.c +0 -369
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_contentby.h +0 -26
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_control.c +0 -483
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_control.h +0 -20
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_coroutine.c +0 -379
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_coroutine.h +0 -23
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_ctx.c +0 -216
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_ctx.h +0 -23
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_directive.c +0 -1081
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_directive.h +0 -56
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_exception.c +0 -58
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_exception.h +0 -33
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headerfilterby.c +0 -302
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headerfilterby.h +0 -29
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headers.c +0 -1370
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headers.h +0 -22
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headers_in.c +0 -782
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headers_in.h +0 -22
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headers_out.c +0 -625
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headers_out.h +0 -23
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_initby.c +0 -42
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_initby.h +0 -23
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_initworkerby.c +0 -320
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_initworkerby.h +0 -25
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_log.c +0 -300
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_log.h +0 -20
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_logby.c +0 -227
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_logby.h +0 -22
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_misc.c +0 -252
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_misc.h +0 -20
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_module.c +0 -924
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_ndk.c +0 -184
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_ndk.h +0 -21
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_output.c +0 -794
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_output.h +0 -28
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_pcrefix.c +0 -106
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_pcrefix.h +0 -23
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_phase.c +0 -94
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_phase.h +0 -13
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_probe.h +0 -85
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_regex.c +0 -2468
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_regex.h +0 -22
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_req_body.c +0 -1169
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_req_body.h +0 -20
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_req_method.c +0 -252
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_req_method.h +0 -19
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_rewriteby.c +0 -351
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_rewriteby.h +0 -22
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_script.c +0 -538
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_script.h +0 -86
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_setby.c +0 -216
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_setby.h +0 -15
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_shdict.c +0 -1844
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_shdict.h +0 -52
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_sleep.c +0 -191
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_sleep.h +0 -20
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_socket_tcp.c +0 -5314
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_socket_tcp.h +0 -156
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_socket_udp.c +0 -1624
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_socket_udp.h +0 -56
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_string.c +0 -704
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_string.h +0 -20
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_subrequest.c +0 -1741
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_subrequest.h +0 -46
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_time.c +0 -278
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_time.h +0 -21
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_timer.c +0 -661
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_timer.h +0 -20
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_uri.c +0 -110
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_uri.h +0 -20
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_uthread.c +0 -283
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_uthread.h +0 -36
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_util.c +0 -3972
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_util.h +0 -423
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_variable.c +0 -499
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_variable.h +0 -20
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_worker.c +0 -64
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_worker.h +0 -17
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/tapset/ngx_lua.stp +0 -5
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/build.sh +0 -39
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/build2.sh +0 -55
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/fix-comments +0 -27
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/gdbinit +0 -415
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/ngx-links +0 -62
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/reindex +0 -64
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/releng +0 -8
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/retab +0 -8
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/revim +0 -102
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/run_test.sh +0 -10
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/update-readme.sh +0 -4
- data/packaging/debian/debian_specs/nginx/modules/nginx-lua/valgrind.suppress +0 -144
- data/packaging/debian/debian_specs/nginx/modules/nginx-upload-progress/CHANGES +0 -107
- data/packaging/debian/debian_specs/nginx/modules/nginx-upload-progress/LICENSE +0 -25
- data/packaging/debian/debian_specs/nginx/modules/nginx-upload-progress/Makefile +0 -8
- data/packaging/debian/debian_specs/nginx/modules/nginx-upload-progress/README +0 -329
- data/packaging/debian/debian_specs/nginx/modules/nginx-upload-progress/config +0 -3
- data/packaging/debian/debian_specs/nginx/modules/nginx-upload-progress/ngx_http_uploadprogress_module.c +0 -1774
- data/packaging/debian/debian_specs/nginx/modules/nginx-upstream-fair/README +0 -53
- data/packaging/debian/debian_specs/nginx/modules/nginx-upstream-fair/config +0 -3
- data/packaging/debian/debian_specs/nginx/modules/nginx-upstream-fair/ngx_http_upstream_fair_module.c +0 -1356
- data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/CHANGELOG.md +0 -37
- data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/HACKING.md +0 -24
- data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/LICENSE +0 -20
- data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/README.rst +0 -182
- data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/config +0 -8
- data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/nginx-0.6-support.patch +0 -23
- data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/ngx_http_fancyindex_module.c +0 -1305
- data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/template.awk +0 -52
- data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/template.h +0 -103
- data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/template.html +0 -102
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/CHANGES +0 -37
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/README +0 -141
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/config +0 -3
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/doc/README.google_code_home_page.wiki +0 -120
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/doc/README.html +0 -199
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/doc/README.wiki +0 -123
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/ngx_http_subs_filter_module.c +0 -1298
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/README +0 -275
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/AutoInstall.pm +0 -820
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install.pm +0 -470
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/AutoInstall.pm +0 -82
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/Base.pm +0 -83
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/Can.pm +0 -81
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/Fetch.pm +0 -93
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/Include.pm +0 -34
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/Makefile.pm +0 -415
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/Metadata.pm +0 -716
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/TestBase.pm +0 -29
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/Win32.pm +0 -64
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/WriteAll.pm +0 -63
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Spiffy.pm +0 -539
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Test/Base.pm +0 -682
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Test/Base/Filter.pm +0 -341
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Test/Builder.pm +0 -1413
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Test/Builder/Module.pm +0 -81
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Test/More.pm +0 -735
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/lib/Test/Nginx.pm +0 -315
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/lib/Test/Nginx/LWP.pm +0 -524
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/lib/Test/Nginx/Socket.pm +0 -1749
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/lib/Test/Nginx/Util.pm +0 -874
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/t/subs.t +0 -136
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/t/subs_capture.t +0 -32
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/t/subs_fix_string.t +0 -32
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/t/subs_regex.t +0 -108
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/t/subs_types.t +0 -59
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/test.sh +0 -5
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/util/update-readme.sh +0 -7
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/util/wiki2google_code_homepage.pl +0 -29
- data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/util/wiki2pod.pl +0 -129
- data/packaging/debian/debian_specs/nginx/nginx-common.NEWS +0 -135
- data/packaging/debian/debian_specs/nginx/nginx-common.README.Debian +0 -45
- data/packaging/debian/debian_specs/nginx/nginx-common.dirs.erb +0 -32
- data/packaging/debian/debian_specs/nginx/nginx-common.install +0 -3
- data/packaging/debian/debian_specs/nginx/nginx-common.lintian-overrides +0 -2
- data/packaging/debian/debian_specs/nginx/nginx-common.manpages +0 -1
- data/packaging/debian/debian_specs/nginx/nginx-common.nginx.default +0 -10
- data/packaging/debian/debian_specs/nginx/nginx-common.nginx.init.erb +0 -214
- data/packaging/debian/debian_specs/nginx/nginx-common.nginx.logrotate +0 -18
- data/packaging/debian/debian_specs/nginx/nginx-common.nginx.service.erb +0 -37
- data/packaging/debian/debian_specs/nginx/nginx-common.postinst.erb +0 -66
- data/packaging/debian/debian_specs/nginx/nginx-common.postrm.erb +0 -46
- data/packaging/debian/debian_specs/nginx/nginx-common.preinst +0 -47
- data/packaging/debian/debian_specs/nginx/nginx-common.prerm.erb +0 -28
- data/packaging/debian/debian_specs/nginx/nginx-doc.docs +0 -2
- data/packaging/debian/debian_specs/nginx/nginx-doc.examples +0 -1
- data/packaging/debian/debian_specs/nginx/nginx-extras.install.erb +0 -17
- data/packaging/debian/debian_specs/nginx/nginx-extras.lintian-overrides +0 -1
- data/packaging/debian/debian_specs/nginx/nginx-extras.postinst.erb +0 -44
- data/packaging/debian/debian_specs/nginx/nginx-extras.prerm +0 -22
- data/packaging/debian/debian_specs/nginx/nginx.1 +0 -47
- data/packaging/debian/debian_specs/nginx/patches/perl-use-dpkg-buildflags.patch +0 -23
- data/packaging/debian/debian_specs/nginx/patches/series +0 -1
- data/packaging/debian/debian_specs/nginx/rules.erb +0 -185
- data/packaging/debian/debian_specs/nginx/source/format +0 -1
- data/packaging/debian/debian_specs/nginx/tests/control +0 -4
- data/packaging/debian/debian_specs/nginx/ufw/nginx +0 -14
- data/packaging/debian/debian_specs/nginx/upstream/signing-key.asc +0 -34
- data/packaging/debian/debian_specs/nginx/watch +0 -3
- data/packaging/debian/debian_specs/passenger/README.Debian +0 -12
- data/packaging/debian/debian_specs/passenger/changelog +0 -316
- data/packaging/debian/debian_specs/passenger/compat +0 -1
- data/packaging/debian/debian_specs/passenger/control.erb +0 -123
- data/packaging/debian/debian_specs/passenger/copyright +0 -385
- data/packaging/debian/debian_specs/passenger/helpers.rb +0 -24
- data/packaging/debian/debian_specs/passenger/libapache2-mod-passenger.install +0 -3
- data/packaging/debian/debian_specs/passenger/libapache2-mod-passenger.postinst +0 -36
- data/packaging/debian/debian_specs/passenger/libapache2-mod-passenger.prerm +0 -15
- data/packaging/debian/debian_specs/passenger/locations.ini.erb +0 -14
- data/packaging/debian/debian_specs/passenger/passenger-dev.install.erb +0 -3
- data/packaging/debian/debian_specs/passenger/passenger-doc.install.erb +0 -2
- data/packaging/debian/debian_specs/passenger/passenger.conf +0 -6
- data/packaging/debian/debian_specs/passenger/passenger.docs +0 -4
- data/packaging/debian/debian_specs/passenger/passenger.install.erb +0 -16
- data/packaging/debian/debian_specs/passenger/passenger.load +0 -3
- data/packaging/debian/debian_specs/passenger/passenger.manpages +0 -3
- data/packaging/debian/debian_specs/passenger/passenger_free_ruby.c +0 -29
- data/packaging/debian/debian_specs/passenger/passenger_ruby_utils.c +0 -54
- data/packaging/debian/debian_specs/passenger/passenger_system_ruby.c.erb +0 -37
- data/packaging/debian/debian_specs/passenger/rules.erb +0 -84
- data/packaging/debian/debian_specs/passenger/source/format +0 -1
- data/packaging/debian/debian_specs/passenger_enterprise/README.Debian +0 -12
- data/packaging/debian/debian_specs/passenger_enterprise/changelog +0 -316
- data/packaging/debian/debian_specs/passenger_enterprise/compat +0 -1
- data/packaging/debian/debian_specs/passenger_enterprise/control.erb +0 -123
- data/packaging/debian/debian_specs/passenger_enterprise/copyright +0 -385
- data/packaging/debian/debian_specs/passenger_enterprise/helpers.rb +0 -2
- data/packaging/debian/debian_specs/passenger_enterprise/libapache2-mod-passenger-enterprise.install +0 -3
- data/packaging/debian/debian_specs/passenger_enterprise/libapache2-mod-passenger-enterprise.postinst +0 -36
- data/packaging/debian/debian_specs/passenger_enterprise/libapache2-mod-passenger-enterprise.prerm +0 -15
- data/packaging/debian/debian_specs/passenger_enterprise/locations.ini.erb +0 -14
- data/packaging/debian/debian_specs/passenger_enterprise/passenger-enterprise-dev.install.erb +0 -3
- data/packaging/debian/debian_specs/passenger_enterprise/passenger-enterprise-doc.install.erb +0 -2
- data/packaging/debian/debian_specs/passenger_enterprise/passenger-enterprise.docs +0 -4
- data/packaging/debian/debian_specs/passenger_enterprise/passenger-enterprise.install.erb +0 -14
- data/packaging/debian/debian_specs/passenger_enterprise/passenger-enterprise.manpages +0 -3
- data/packaging/debian/debian_specs/passenger_enterprise/passenger.conf +0 -6
- data/packaging/debian/debian_specs/passenger_enterprise/passenger.load +0 -3
- data/packaging/debian/debian_specs/passenger_enterprise/passenger_free_ruby.c.erb +0 -1
- data/packaging/debian/debian_specs/passenger_enterprise/passenger_ruby_utils.c.erb +0 -1
- data/packaging/debian/debian_specs/passenger_enterprise/passenger_system_ruby.c.erb +0 -1
- data/packaging/debian/debian_specs/passenger_enterprise/patches/series +0 -0
- data/packaging/debian/debian_specs/passenger_enterprise/rules.erb +0 -84
- data/packaging/debian/debian_specs/passenger_enterprise/source/format +0 -1
- data/packaging/debian/docker_images/Makefile +0 -38
- data/packaging/debian/docker_images/buildbox/CONTAINER_VERSION.txt +0 -0
- data/packaging/debian/docker_images/buildbox/Dockerfile +0 -3
- data/packaging/debian/docker_images/buildbox/Gemfile +0 -9
- data/packaging/debian/docker_images/buildbox/Gemfile.lock +0 -42
- data/packaging/debian/docker_images/buildbox/install.sh +0 -85
- data/packaging/debian/docker_images/buildbox/pbuilderrc +0 -4
- data/packaging/debian/docker_images/buildbox/sudoers.conf +0 -6
- data/packaging/debian/docker_images/setup-buildbox-docker-image +0 -7
- data/packaging/debian/docker_images/setup-testbox-docker-image-debian-6 +0 -7
- data/packaging/debian/docker_images/setup-testbox-docker-image-debian-7 +0 -7
- data/packaging/debian/docker_images/setup-testbox-docker-image-debian-8 +0 -7
- data/packaging/debian/docker_images/setup-testbox-docker-image-ubuntu-12.04 +0 -7
- data/packaging/debian/docker_images/setup-testbox-docker-image-ubuntu-14.04 +0 -7
- data/packaging/debian/docker_images/setup-testbox-docker-image-ubuntu-15.04 +0 -7
- data/packaging/debian/docker_images/setup-testbox-docker-image-ubuntu-15.10 +0 -7
- data/packaging/debian/docker_images/testbox-debian-6/Dockerfile +0 -3
- data/packaging/debian/docker_images/testbox-debian-6/Gemfile +0 -2
- data/packaging/debian/docker_images/testbox-debian-6/Gemfile.lock +0 -23
- data/packaging/debian/docker_images/testbox-debian-6/argparse.py +0 -2374
- data/packaging/debian/docker_images/testbox-debian-6/install.sh +0 -78
- data/packaging/debian/docker_images/testbox-debian-7/Dockerfile +0 -3
- data/packaging/debian/docker_images/testbox-debian-7/Gemfile +0 -2
- data/packaging/debian/docker_images/testbox-debian-7/Gemfile.lock +0 -23
- data/packaging/debian/docker_images/testbox-debian-7/install.sh +0 -71
- data/packaging/debian/docker_images/testbox-debian-8/Dockerfile +0 -3
- data/packaging/debian/docker_images/testbox-debian-8/Gemfile +0 -2
- data/packaging/debian/docker_images/testbox-debian-8/Gemfile.lock +0 -23
- data/packaging/debian/docker_images/testbox-debian-8/install.sh +0 -70
- data/packaging/debian/docker_images/testbox-ubuntu-12.04/Dockerfile +0 -3
- data/packaging/debian/docker_images/testbox-ubuntu-12.04/Gemfile +0 -2
- data/packaging/debian/docker_images/testbox-ubuntu-12.04/Gemfile.lock +0 -23
- data/packaging/debian/docker_images/testbox-ubuntu-12.04/install.sh +0 -69
- data/packaging/debian/docker_images/testbox-ubuntu-14.04/Dockerfile +0 -3
- data/packaging/debian/docker_images/testbox-ubuntu-14.04/Gemfile +0 -2
- data/packaging/debian/docker_images/testbox-ubuntu-14.04/Gemfile.lock +0 -23
- data/packaging/debian/docker_images/testbox-ubuntu-14.04/install.sh +0 -69
- data/packaging/debian/docker_images/testbox-ubuntu-15.04/Dockerfile +0 -3
- data/packaging/debian/docker_images/testbox-ubuntu-15.04/Gemfile +0 -2
- data/packaging/debian/docker_images/testbox-ubuntu-15.04/Gemfile.lock +0 -23
- data/packaging/debian/docker_images/testbox-ubuntu-15.04/install.sh +0 -69
- data/packaging/debian/docker_images/testbox-ubuntu-15.10/Dockerfile +0 -3
- data/packaging/debian/docker_images/testbox-ubuntu-15.10/Gemfile +0 -2
- data/packaging/debian/docker_images/testbox-ubuntu-15.10/Gemfile.lock +0 -23
- data/packaging/debian/docker_images/testbox-ubuntu-15.10/install.sh +0 -69
- data/packaging/debian/internal/build/Rakefile +0 -235
- data/packaging/debian/internal/build/build-passenger-orig-tarball.sh +0 -76
- data/packaging/debian/internal/build/build-source-package.rb +0 -121
- data/packaging/debian/internal/build/download-nginx-orig-tarball.sh +0 -17
- data/packaging/debian/internal/build/rakefile_support.rb +0 -96
- data/packaging/debian/internal/build/setup-environment-essentials.sh +0 -15
- data/packaging/debian/internal/build/setup-environment.sh +0 -29
- data/packaging/debian/internal/lib/distro_info.rb +0 -82
- data/packaging/debian/internal/lib/distro_info.sh +0 -303
- data/packaging/debian/internal/lib/distro_info.sh.erb +0 -65
- data/packaging/debian/internal/lib/library.sh +0 -83
- data/packaging/debian/internal/lib/preprocessor.rb +0 -173
- data/packaging/debian/internal/lib/tracking.rb +0 -95
- data/packaging/debian/internal/lib/tracking_category.rb +0 -45
- data/packaging/debian/internal/lib/tracking_database.rb +0 -132
- data/packaging/debian/internal/lib/tracking_task.rb +0 -148
- data/packaging/debian/internal/lib/utils.rb +0 -78
- data/packaging/debian/internal/publish/Rakefile +0 -97
- data/packaging/debian/internal/publish/oss-binaries.phusionpassenger.com-fingerprint.txt +0 -1
- data/packaging/debian/internal/publish/packagecloud_fingerprint.txt +0 -1
- data/packaging/debian/internal/publish/passenger_website_fingerprint.txt +0 -1
- data/packaging/debian/internal/publish/preinit.sh +0 -7
- data/packaging/debian/internal/publish/rakefile_support.rb +0 -183
- data/packaging/debian/internal/scripts/gpg_noninteractive/gpg +0 -11
- data/packaging/debian/internal/scripts/initccache.sh +0 -35
- data/packaging/debian/internal/scripts/inituidgid.sh +0 -19
- data/packaging/debian/internal/scripts/my_init +0 -340
- data/packaging/debian/internal/scripts/pin_certificates +0 -34
- data/packaging/debian/internal/scripts/regen_distro_info_script.sh +0 -3
- data/packaging/debian/internal/scripts/setup-vagrant.sh +0 -12
- data/packaging/debian/internal/scripts/setuser +0 -31
- data/packaging/debian/internal/shell/initpbuilder.sh +0 -3
- data/packaging/debian/internal/shell/preinit.sh +0 -28
- data/packaging/debian/internal/shell/sudoers.conf +0 -1
- data/packaging/debian/internal/test/apache/apache-24.conf +0 -5
- data/packaging/debian/internal/test/apache/apache-pre-24.conf +0 -4
- data/packaging/debian/internal/test/apache/vhost.conf +0 -17
- data/packaging/debian/internal/test/misc/config.json +0 -15
- data/packaging/debian/internal/test/misc/hosts.conf +0 -4
- data/packaging/debian/internal/test/misc/init.sh +0 -25
- data/packaging/debian/internal/test/misc/nodejs_test_app.js +0 -6
- data/packaging/debian/internal/test/misc/python_test_app.py +0 -3
- data/packaging/debian/internal/test/misc/ruby_test_app.rb +0 -5
- data/packaging/debian/internal/test/misc/test_support.rb +0 -61
- data/packaging/debian/internal/test/nginx/vhost.conf +0 -23
- data/packaging/debian/internal/test/system_web_server_test.rb +0 -126
- data/packaging/debian/internal/test/test.sh +0 -141
- data/packaging/debian/jenkins/publish/clear_caches.rb +0 -48
- data/packaging/debian/jenkins/publish/publish.sh +0 -69
- data/packaging/debian/jenkins/test/test.sh +0 -63
- data/packaging/debian/passenger_apt_automation.sublime-project +0 -14
- data/packaging/debian/publish +0 -172
- data/packaging/debian/shell +0 -116
- data/packaging/debian/test +0 -142
- data/packaging/rpm/passenger_spec/rubygem-passenger-4.0.18-gcc47-include-sys_types.patch +0 -45
- data/test/cxx/Base64Test.cpp +0 -50
- data/test/cxx/FileBackedPipeTest.cpp +0 -626
- data/test/cxx/HttpHeaderBuffererTest.cpp +0 -257
- data/test/cxx/ScgiRequestParserTest.cpp +0 -423
- data/test/cxx/ServerInstanceDirTest.cpp +0 -175
- data/test/ruby/admin_tools_spec.rb +0 -360
- data/test/ruby/classic_rails/loader_spec.rb +0 -46
- data/test/ruby/classic_rails/preloader_spec.rb +0 -52
- data/test/ruby/standalone/runtime_locator_spec.rb +0 -214
- data/test/stub/rails2.3/Rakefile +0 -10
- data/test/stub/rails2.3/app/controllers/application_controller.rb +0 -10
- data/test/stub/rails2.3/app/controllers/bar_controller_1.rb +0 -5
- data/test/stub/rails2.3/app/controllers/bar_controller_2.rb +0 -5
- data/test/stub/rails2.3/app/controllers/foo_controller.rb +0 -21
- data/test/stub/rails2.3/app/helpers/application_helper.rb +0 -3
- data/test/stub/rails2.3/app/helpers/bar_helper.rb +0 -2
- data/test/stub/rails2.3/app/helpers/foo_helper.rb +0 -2
- data/test/stub/rails2.3/config/boot.rb +0 -110
- data/test/stub/rails2.3/config/database.yml +0 -19
- data/test/stub/rails2.3/config/environment.rb +0 -62
- data/test/stub/rails2.3/config/environments/development.rb +0 -17
- data/test/stub/rails2.3/config/environments/production.rb +0 -18
- data/test/stub/rails2.3/config/environments/staging.rb +0 -18
- data/test/stub/rails2.3/config/initializers/inflections.rb +0 -10
- data/test/stub/rails2.3/config/initializers/mime_types.rb +0 -5
- data/test/stub/rails2.3/config/routes.rb +0 -35
- data/test/stub/rails2.3/log/.gitignore +0 -1
- data/test/stub/rails2.3/public/.gitignore +0 -1
- data/test/stub/rails2.3/script/about +0 -3
- data/test/stub/rails2.3/script/console +0 -3
- data/test/stub/rails2.3/script/dbconsole +0 -3
- data/test/stub/rails2.3/script/destroy +0 -3
- data/test/stub/rails2.3/script/generate +0 -3
- data/test/stub/rails2.3/script/performance/benchmarker +0 -3
- data/test/stub/rails2.3/script/performance/profiler +0 -3
- data/test/stub/rails2.3/script/performance/request +0 -3
- data/test/stub/rails2.3/script/plugin +0 -3
- data/test/stub/rails2.3/script/process/inspector +0 -3
- data/test/stub/rails2.3/script/process/reaper +0 -3
- data/test/stub/rails2.3/script/process/spawner +0 -3
- data/test/stub/rails2.3/script/runner +0 -3
- data/test/stub/rails2.3/script/server +0 -3
- data/test/stub/rails2.3/tmp/cache/.gitignore +0 -1
- data/test/stub/rails2.3/tmp/pids/.gitignore +0 -1
- data/test/stub/rails2.3/tmp/sessions/.gitignore +0 -1
- data/test/stub/rails2.3/tmp/sockets/.gitignore +0 -1
@@ -1,3972 +0,0 @@
|
|
1
|
-
|
2
|
-
/*
|
3
|
-
* Copyright (C) Xiaozhe Wang (chaoslawful)
|
4
|
-
* Copyright (C) Yichun Zhang (agentzh)
|
5
|
-
*/
|
6
|
-
|
7
|
-
|
8
|
-
#ifndef DDEBUG
|
9
|
-
#define DDEBUG 0
|
10
|
-
#endif
|
11
|
-
#include "ddebug.h"
|
12
|
-
|
13
|
-
|
14
|
-
#include "nginx.h"
|
15
|
-
#include "ngx_http_lua_directive.h"
|
16
|
-
#include "ngx_http_lua_util.h"
|
17
|
-
#include "ngx_http_lua_exception.h"
|
18
|
-
#include "ngx_http_lua_pcrefix.h"
|
19
|
-
#include "ngx_http_lua_regex.h"
|
20
|
-
#include "ngx_http_lua_args.h"
|
21
|
-
#include "ngx_http_lua_uri.h"
|
22
|
-
#include "ngx_http_lua_req_body.h"
|
23
|
-
#include "ngx_http_lua_headers.h"
|
24
|
-
#include "ngx_http_lua_output.h"
|
25
|
-
#include "ngx_http_lua_time.h"
|
26
|
-
#include "ngx_http_lua_control.h"
|
27
|
-
#include "ngx_http_lua_ndk.h"
|
28
|
-
#include "ngx_http_lua_subrequest.h"
|
29
|
-
#include "ngx_http_lua_log.h"
|
30
|
-
#include "ngx_http_lua_variable.h"
|
31
|
-
#include "ngx_http_lua_string.h"
|
32
|
-
#include "ngx_http_lua_misc.h"
|
33
|
-
#include "ngx_http_lua_consts.h"
|
34
|
-
#include "ngx_http_lua_req_method.h"
|
35
|
-
#include "ngx_http_lua_shdict.h"
|
36
|
-
#include "ngx_http_lua_coroutine.h"
|
37
|
-
#include "ngx_http_lua_socket_tcp.h"
|
38
|
-
#include "ngx_http_lua_socket_udp.h"
|
39
|
-
#include "ngx_http_lua_sleep.h"
|
40
|
-
#include "ngx_http_lua_setby.h"
|
41
|
-
#include "ngx_http_lua_headerfilterby.h"
|
42
|
-
#include "ngx_http_lua_bodyfilterby.h"
|
43
|
-
#include "ngx_http_lua_logby.h"
|
44
|
-
#include "ngx_http_lua_phase.h"
|
45
|
-
#include "ngx_http_lua_probe.h"
|
46
|
-
#include "ngx_http_lua_uthread.h"
|
47
|
-
#include "ngx_http_lua_contentby.h"
|
48
|
-
#include "ngx_http_lua_timer.h"
|
49
|
-
#include "ngx_http_lua_config.h"
|
50
|
-
#include "ngx_http_lua_worker.h"
|
51
|
-
#include "ngx_http_lua_socket_tcp.h"
|
52
|
-
|
53
|
-
|
54
|
-
#if 1
|
55
|
-
#undef ngx_http_lua_probe_info
|
56
|
-
#define ngx_http_lua_probe_info(msg)
|
57
|
-
#endif
|
58
|
-
|
59
|
-
|
60
|
-
#ifndef NGX_HTTP_LUA_BT_DEPTH
|
61
|
-
#define NGX_HTTP_LUA_BT_DEPTH 22
|
62
|
-
#endif
|
63
|
-
|
64
|
-
|
65
|
-
#ifndef NGX_HTTP_LUA_BT_MAX_COROS
|
66
|
-
#define NGX_HTTP_LUA_BT_MAX_COROS 5
|
67
|
-
#endif
|
68
|
-
|
69
|
-
|
70
|
-
char ngx_http_lua_code_cache_key;
|
71
|
-
char ngx_http_lua_regex_cache_key;
|
72
|
-
char ngx_http_lua_socket_pool_key;
|
73
|
-
char ngx_http_lua_coroutines_key;
|
74
|
-
char ngx_http_lua_headers_metatable_key;
|
75
|
-
|
76
|
-
|
77
|
-
ngx_uint_t ngx_http_lua_location_hash = 0;
|
78
|
-
ngx_uint_t ngx_http_lua_content_length_hash = 0;
|
79
|
-
|
80
|
-
|
81
|
-
static ngx_int_t ngx_http_lua_send_http10_headers(ngx_http_request_t *r,
|
82
|
-
ngx_http_lua_ctx_t *ctx);
|
83
|
-
static void ngx_http_lua_init_registry(lua_State *L, ngx_log_t *log);
|
84
|
-
static void ngx_http_lua_init_globals(lua_State *L, ngx_cycle_t *cycle,
|
85
|
-
ngx_http_lua_main_conf_t *lmcf, ngx_log_t *log);
|
86
|
-
static void ngx_http_lua_set_path(ngx_cycle_t *cycle, lua_State *L, int tab_idx,
|
87
|
-
const char *fieldname, const char *path, const char *default_path,
|
88
|
-
ngx_log_t *log);
|
89
|
-
static ngx_int_t ngx_http_lua_handle_exec(lua_State *L, ngx_http_request_t *r,
|
90
|
-
ngx_http_lua_ctx_t *ctx);
|
91
|
-
static ngx_int_t ngx_http_lua_handle_exit(lua_State *L, ngx_http_request_t *r,
|
92
|
-
ngx_http_lua_ctx_t *ctx);
|
93
|
-
static ngx_int_t ngx_http_lua_handle_rewrite_jump(lua_State *L,
|
94
|
-
ngx_http_request_t *r, ngx_http_lua_ctx_t *ctx);
|
95
|
-
static int ngx_http_lua_thread_traceback(lua_State *L, lua_State *co,
|
96
|
-
ngx_http_lua_co_ctx_t *coctx);
|
97
|
-
static void ngx_http_lua_inject_ngx_api(lua_State *L,
|
98
|
-
ngx_http_lua_main_conf_t *lmcf, ngx_log_t *log);
|
99
|
-
static void ngx_http_lua_inject_arg_api(lua_State *L);
|
100
|
-
static int ngx_http_lua_param_get(lua_State *L);
|
101
|
-
static int ngx_http_lua_param_set(lua_State *L);
|
102
|
-
static ngx_int_t ngx_http_lua_output_filter(ngx_http_request_t *r,
|
103
|
-
ngx_chain_t *in);
|
104
|
-
static ngx_int_t ngx_http_lua_send_special(ngx_http_request_t *r,
|
105
|
-
ngx_uint_t flags);
|
106
|
-
static void ngx_http_lua_finalize_threads(ngx_http_request_t *r,
|
107
|
-
ngx_http_lua_ctx_t *ctx, lua_State *L);
|
108
|
-
static ngx_int_t ngx_http_lua_post_zombie_thread(ngx_http_request_t *r,
|
109
|
-
ngx_http_lua_co_ctx_t *parent, ngx_http_lua_co_ctx_t *thread);
|
110
|
-
static void ngx_http_lua_cleanup_zombie_child_uthreads(ngx_http_request_t *r,
|
111
|
-
lua_State *L, ngx_http_lua_ctx_t *ctx, ngx_http_lua_co_ctx_t *coctx);
|
112
|
-
static ngx_int_t ngx_http_lua_on_abort_resume(ngx_http_request_t *r);
|
113
|
-
static void ngx_http_lua_close_fake_request(ngx_http_request_t *r);
|
114
|
-
static void ngx_http_lua_free_fake_request(ngx_http_request_t *r);
|
115
|
-
static ngx_int_t ngx_http_lua_flush_pending_output(ngx_http_request_t *r,
|
116
|
-
ngx_http_lua_ctx_t *ctx);
|
117
|
-
static ngx_int_t
|
118
|
-
ngx_http_lua_process_flushing_coroutines(ngx_http_request_t *r,
|
119
|
-
ngx_http_lua_ctx_t *ctx);
|
120
|
-
static lua_State * ngx_http_lua_new_state(lua_State *parent_vm,
|
121
|
-
ngx_cycle_t *cycle, ngx_http_lua_main_conf_t *lmcf, ngx_log_t *log);
|
122
|
-
static int ngx_http_lua_get_raw_phase_context(lua_State *L);
|
123
|
-
|
124
|
-
|
125
|
-
#ifndef LUA_PATH_SEP
|
126
|
-
#define LUA_PATH_SEP ";"
|
127
|
-
#endif
|
128
|
-
|
129
|
-
#define AUX_MARK "\1"
|
130
|
-
|
131
|
-
|
132
|
-
static void
|
133
|
-
ngx_http_lua_set_path(ngx_cycle_t *cycle, lua_State *L, int tab_idx,
|
134
|
-
const char *fieldname, const char *path, const char *default_path,
|
135
|
-
ngx_log_t *log)
|
136
|
-
{
|
137
|
-
const char *tmp_path;
|
138
|
-
const char *prefix;
|
139
|
-
|
140
|
-
/* XXX here we use some hack to simplify string manipulation */
|
141
|
-
tmp_path = luaL_gsub(L, path, LUA_PATH_SEP LUA_PATH_SEP,
|
142
|
-
LUA_PATH_SEP AUX_MARK LUA_PATH_SEP);
|
143
|
-
|
144
|
-
lua_pushlstring(L, (char *) cycle->prefix.data, cycle->prefix.len);
|
145
|
-
prefix = lua_tostring(L, -1);
|
146
|
-
tmp_path = luaL_gsub(L, tmp_path, "$prefix", prefix);
|
147
|
-
tmp_path = luaL_gsub(L, tmp_path, "${prefix}", prefix);
|
148
|
-
lua_pop(L, 3);
|
149
|
-
|
150
|
-
dd("tmp_path path: %s", tmp_path);
|
151
|
-
|
152
|
-
#if (NGX_DEBUG)
|
153
|
-
tmp_path =
|
154
|
-
#else
|
155
|
-
(void)
|
156
|
-
#endif
|
157
|
-
luaL_gsub(L, tmp_path, AUX_MARK, default_path);
|
158
|
-
|
159
|
-
#if (NGX_DEBUG)
|
160
|
-
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, log, 0,
|
161
|
-
"lua setting lua package.%s to \"%s\"", fieldname, tmp_path);
|
162
|
-
#endif
|
163
|
-
|
164
|
-
lua_remove(L, -2);
|
165
|
-
|
166
|
-
/* fix negative index as there's new data on stack */
|
167
|
-
tab_idx = (tab_idx < 0) ? (tab_idx - 1) : tab_idx;
|
168
|
-
lua_setfield(L, tab_idx, fieldname);
|
169
|
-
}
|
170
|
-
|
171
|
-
|
172
|
-
/**
|
173
|
-
* Create new table and set _G field to itself.
|
174
|
-
*
|
175
|
-
* After:
|
176
|
-
* | new table | <- top
|
177
|
-
* | ... |
|
178
|
-
* */
|
179
|
-
void
|
180
|
-
ngx_http_lua_create_new_globals_table(lua_State *L, int narr, int nrec)
|
181
|
-
{
|
182
|
-
lua_createtable(L, narr, nrec + 1);
|
183
|
-
lua_pushvalue(L, -1);
|
184
|
-
lua_setfield(L, -2, "_G");
|
185
|
-
}
|
186
|
-
|
187
|
-
|
188
|
-
static lua_State *
|
189
|
-
ngx_http_lua_new_state(lua_State *parent_vm, ngx_cycle_t *cycle,
|
190
|
-
ngx_http_lua_main_conf_t *lmcf, ngx_log_t *log)
|
191
|
-
{
|
192
|
-
lua_State *L;
|
193
|
-
const char *old_path;
|
194
|
-
const char *new_path;
|
195
|
-
size_t old_path_len;
|
196
|
-
const char *old_cpath;
|
197
|
-
const char *new_cpath;
|
198
|
-
size_t old_cpath_len;
|
199
|
-
|
200
|
-
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, log, 0, "lua creating new vm state");
|
201
|
-
|
202
|
-
L = luaL_newstate();
|
203
|
-
if (L == NULL) {
|
204
|
-
return NULL;
|
205
|
-
}
|
206
|
-
|
207
|
-
luaL_openlibs(L);
|
208
|
-
|
209
|
-
lua_getglobal(L, "package");
|
210
|
-
|
211
|
-
if (!lua_istable(L, -1)) {
|
212
|
-
ngx_log_error(NGX_LOG_EMERG, log, 0,
|
213
|
-
"the \"package\" table does not exist");
|
214
|
-
return NULL;
|
215
|
-
}
|
216
|
-
|
217
|
-
if (parent_vm) {
|
218
|
-
lua_getglobal(parent_vm, "package");
|
219
|
-
lua_getfield(parent_vm, -1, "path");
|
220
|
-
old_path = lua_tolstring(parent_vm, -1, &old_path_len);
|
221
|
-
lua_pop(parent_vm, 1);
|
222
|
-
|
223
|
-
lua_pushlstring(L, old_path, old_path_len);
|
224
|
-
lua_setfield(L, -2, "path");
|
225
|
-
|
226
|
-
lua_getfield(parent_vm, -1, "cpath");
|
227
|
-
old_path = lua_tolstring(parent_vm, -1, &old_path_len);
|
228
|
-
lua_pop(parent_vm, 2);
|
229
|
-
|
230
|
-
lua_pushlstring(L, old_path, old_path_len);
|
231
|
-
lua_setfield(L, -2, "cpath");
|
232
|
-
|
233
|
-
} else {
|
234
|
-
#ifdef LUA_DEFAULT_PATH
|
235
|
-
# define LUA_DEFAULT_PATH_LEN (sizeof(LUA_DEFAULT_PATH) - 1)
|
236
|
-
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0,
|
237
|
-
"lua prepending default package.path with %s",
|
238
|
-
LUA_DEFAULT_PATH);
|
239
|
-
|
240
|
-
lua_pushliteral(L, LUA_DEFAULT_PATH ";"); /* package default */
|
241
|
-
lua_getfield(L, -2, "path"); /* package default old */
|
242
|
-
old_path = lua_tolstring(L, -1, &old_path_len);
|
243
|
-
lua_concat(L, 2); /* package new */
|
244
|
-
lua_setfield(L, -2, "path"); /* package */
|
245
|
-
#endif
|
246
|
-
|
247
|
-
#ifdef LUA_DEFAULT_CPATH
|
248
|
-
# define LUA_DEFAULT_CPATH_LEN (sizeof(LUA_DEFAULT_CPATH) - 1)
|
249
|
-
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0,
|
250
|
-
"lua prepending default package.cpath with %s",
|
251
|
-
LUA_DEFAULT_CPATH);
|
252
|
-
|
253
|
-
lua_pushliteral(L, LUA_DEFAULT_CPATH ";"); /* package default */
|
254
|
-
lua_getfield(L, -2, "cpath"); /* package default old */
|
255
|
-
old_cpath = lua_tolstring(L, -1, &old_cpath_len);
|
256
|
-
lua_concat(L, 2); /* package new */
|
257
|
-
lua_setfield(L, -2, "cpath"); /* package */
|
258
|
-
#endif
|
259
|
-
|
260
|
-
if (lmcf->lua_path.len != 0) {
|
261
|
-
lua_getfield(L, -1, "path"); /* get original package.path */
|
262
|
-
old_path = lua_tolstring(L, -1, &old_path_len);
|
263
|
-
|
264
|
-
dd("old path: %s", old_path);
|
265
|
-
|
266
|
-
lua_pushlstring(L, (char *) lmcf->lua_path.data,
|
267
|
-
lmcf->lua_path.len);
|
268
|
-
new_path = lua_tostring(L, -1);
|
269
|
-
|
270
|
-
ngx_http_lua_set_path(cycle, L, -3, "path", new_path, old_path,
|
271
|
-
log);
|
272
|
-
|
273
|
-
lua_pop(L, 2);
|
274
|
-
}
|
275
|
-
|
276
|
-
if (lmcf->lua_cpath.len != 0) {
|
277
|
-
lua_getfield(L, -1, "cpath"); /* get original package.cpath */
|
278
|
-
old_cpath = lua_tolstring(L, -1, &old_cpath_len);
|
279
|
-
|
280
|
-
dd("old cpath: %s", old_cpath);
|
281
|
-
|
282
|
-
lua_pushlstring(L, (char *) lmcf->lua_cpath.data,
|
283
|
-
lmcf->lua_cpath.len);
|
284
|
-
new_cpath = lua_tostring(L, -1);
|
285
|
-
|
286
|
-
ngx_http_lua_set_path(cycle, L, -3, "cpath", new_cpath, old_cpath,
|
287
|
-
log);
|
288
|
-
|
289
|
-
|
290
|
-
lua_pop(L, 2);
|
291
|
-
}
|
292
|
-
}
|
293
|
-
|
294
|
-
lua_pop(L, 1); /* remove the "package" table */
|
295
|
-
|
296
|
-
ngx_http_lua_init_registry(L, log);
|
297
|
-
ngx_http_lua_init_globals(L, cycle, lmcf, log);
|
298
|
-
|
299
|
-
return L;
|
300
|
-
}
|
301
|
-
|
302
|
-
|
303
|
-
lua_State *
|
304
|
-
ngx_http_lua_new_thread(ngx_http_request_t *r, lua_State *L, int *ref)
|
305
|
-
{
|
306
|
-
int base;
|
307
|
-
lua_State *co;
|
308
|
-
|
309
|
-
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
310
|
-
"lua creating new thread");
|
311
|
-
|
312
|
-
base = lua_gettop(L);
|
313
|
-
|
314
|
-
lua_pushlightuserdata(L, &ngx_http_lua_coroutines_key);
|
315
|
-
lua_rawget(L, LUA_REGISTRYINDEX);
|
316
|
-
|
317
|
-
co = lua_newthread(L);
|
318
|
-
|
319
|
-
/* {{{ inherit coroutine's globals to main thread's globals table
|
320
|
-
* for print() function will try to find tostring() in current
|
321
|
-
* globals table.
|
322
|
-
*/
|
323
|
-
/* new globals table for coroutine */
|
324
|
-
ngx_http_lua_create_new_globals_table(co, 0, 0);
|
325
|
-
|
326
|
-
lua_createtable(co, 0, 1);
|
327
|
-
ngx_http_lua_get_globals_table(co);
|
328
|
-
lua_setfield(co, -2, "__index");
|
329
|
-
lua_setmetatable(co, -2);
|
330
|
-
|
331
|
-
ngx_http_lua_set_globals_table(co);
|
332
|
-
/* }}} */
|
333
|
-
|
334
|
-
*ref = luaL_ref(L, -2);
|
335
|
-
|
336
|
-
if (*ref == LUA_NOREF) {
|
337
|
-
lua_settop(L, base); /* restore main thread stack */
|
338
|
-
return NULL;
|
339
|
-
}
|
340
|
-
|
341
|
-
lua_settop(L, base);
|
342
|
-
return co;
|
343
|
-
}
|
344
|
-
|
345
|
-
|
346
|
-
void
|
347
|
-
ngx_http_lua_del_thread(ngx_http_request_t *r, lua_State *L,
|
348
|
-
ngx_http_lua_ctx_t *ctx, ngx_http_lua_co_ctx_t *coctx)
|
349
|
-
{
|
350
|
-
if (coctx->co_ref == LUA_NOREF) {
|
351
|
-
return;
|
352
|
-
}
|
353
|
-
|
354
|
-
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
355
|
-
"lua deleting light thread");
|
356
|
-
|
357
|
-
lua_pushlightuserdata(L, &ngx_http_lua_coroutines_key);
|
358
|
-
lua_rawget(L, LUA_REGISTRYINDEX);
|
359
|
-
|
360
|
-
ngx_http_lua_probe_thread_delete(r, coctx->co, ctx);
|
361
|
-
|
362
|
-
luaL_unref(L, -1, coctx->co_ref);
|
363
|
-
coctx->co_ref = LUA_NOREF;
|
364
|
-
coctx->co_status = NGX_HTTP_LUA_CO_DEAD;
|
365
|
-
|
366
|
-
lua_pop(L, 1);
|
367
|
-
}
|
368
|
-
|
369
|
-
|
370
|
-
u_char *
|
371
|
-
ngx_http_lua_rebase_path(ngx_pool_t *pool, u_char *src, size_t len)
|
372
|
-
{
|
373
|
-
u_char *p, *dst;
|
374
|
-
|
375
|
-
if (len == 0) {
|
376
|
-
return NULL;
|
377
|
-
}
|
378
|
-
|
379
|
-
if (src[0] == '/') {
|
380
|
-
/* being an absolute path already */
|
381
|
-
dst = ngx_palloc(pool, len + 1);
|
382
|
-
if (dst == NULL) {
|
383
|
-
return NULL;
|
384
|
-
}
|
385
|
-
|
386
|
-
p = ngx_copy(dst, src, len);
|
387
|
-
|
388
|
-
*p = '\0';
|
389
|
-
|
390
|
-
return dst;
|
391
|
-
}
|
392
|
-
|
393
|
-
dst = ngx_palloc(pool, ngx_cycle->prefix.len + len + 1);
|
394
|
-
if (dst == NULL) {
|
395
|
-
return NULL;
|
396
|
-
}
|
397
|
-
|
398
|
-
p = ngx_copy(dst, ngx_cycle->prefix.data, ngx_cycle->prefix.len);
|
399
|
-
p = ngx_copy(p, src, len);
|
400
|
-
|
401
|
-
*p = '\0';
|
402
|
-
|
403
|
-
return dst;
|
404
|
-
}
|
405
|
-
|
406
|
-
|
407
|
-
ngx_int_t
|
408
|
-
ngx_http_lua_send_header_if_needed(ngx_http_request_t *r,
|
409
|
-
ngx_http_lua_ctx_t *ctx)
|
410
|
-
{
|
411
|
-
ngx_int_t rc;
|
412
|
-
|
413
|
-
if (!r->header_sent) {
|
414
|
-
if (r->headers_out.status == 0) {
|
415
|
-
r->headers_out.status = NGX_HTTP_OK;
|
416
|
-
}
|
417
|
-
|
418
|
-
if (!ctx->headers_set && ngx_http_lua_set_content_type(r) != NGX_OK) {
|
419
|
-
return NGX_ERROR;
|
420
|
-
}
|
421
|
-
|
422
|
-
if (!ctx->headers_set) {
|
423
|
-
ngx_http_clear_content_length(r);
|
424
|
-
ngx_http_clear_accept_ranges(r);
|
425
|
-
}
|
426
|
-
|
427
|
-
if (!ctx->buffering) {
|
428
|
-
dd("sending headers");
|
429
|
-
rc = ngx_http_send_header(r);
|
430
|
-
return rc;
|
431
|
-
}
|
432
|
-
}
|
433
|
-
|
434
|
-
return NGX_OK;
|
435
|
-
}
|
436
|
-
|
437
|
-
|
438
|
-
ngx_int_t
|
439
|
-
ngx_http_lua_send_chain_link(ngx_http_request_t *r, ngx_http_lua_ctx_t *ctx,
|
440
|
-
ngx_chain_t *in)
|
441
|
-
{
|
442
|
-
ngx_int_t rc;
|
443
|
-
ngx_chain_t *cl;
|
444
|
-
ngx_chain_t **ll;
|
445
|
-
ngx_http_lua_loc_conf_t *llcf;
|
446
|
-
|
447
|
-
#if 1
|
448
|
-
if (ctx->acquired_raw_req_socket || ctx->eof) {
|
449
|
-
dd("ctx->eof already set or raw req socket already acquired");
|
450
|
-
return NGX_OK;
|
451
|
-
}
|
452
|
-
#endif
|
453
|
-
|
454
|
-
if ((r->method & NGX_HTTP_HEAD) && !r->header_only) {
|
455
|
-
r->header_only = 1;
|
456
|
-
}
|
457
|
-
|
458
|
-
llcf = ngx_http_get_module_loc_conf(r, ngx_http_lua_module);
|
459
|
-
|
460
|
-
if (llcf->http10_buffering
|
461
|
-
&& !ctx->buffering
|
462
|
-
&& !r->header_sent
|
463
|
-
&& r->http_version < NGX_HTTP_VERSION_11
|
464
|
-
&& r->headers_out.content_length_n < 0)
|
465
|
-
{
|
466
|
-
ctx->buffering = 1;
|
467
|
-
}
|
468
|
-
|
469
|
-
rc = ngx_http_lua_send_header_if_needed(r, ctx);
|
470
|
-
|
471
|
-
if (rc == NGX_ERROR || rc > NGX_OK) {
|
472
|
-
return rc;
|
473
|
-
}
|
474
|
-
|
475
|
-
if (r->header_only) {
|
476
|
-
ctx->eof = 1;
|
477
|
-
|
478
|
-
if (ctx->buffering) {
|
479
|
-
return ngx_http_lua_send_http10_headers(r, ctx);
|
480
|
-
}
|
481
|
-
|
482
|
-
return rc;
|
483
|
-
}
|
484
|
-
|
485
|
-
if (in == NULL) {
|
486
|
-
if (ctx->buffering) {
|
487
|
-
rc = ngx_http_lua_send_http10_headers(r, ctx);
|
488
|
-
if (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE) {
|
489
|
-
return rc;
|
490
|
-
}
|
491
|
-
|
492
|
-
if (ctx->out) {
|
493
|
-
|
494
|
-
rc = ngx_http_lua_output_filter(r, ctx->out);
|
495
|
-
|
496
|
-
if (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE) {
|
497
|
-
return rc;
|
498
|
-
}
|
499
|
-
|
500
|
-
ctx->out = NULL;
|
501
|
-
}
|
502
|
-
}
|
503
|
-
|
504
|
-
#if defined(nginx_version) && nginx_version <= 8004
|
505
|
-
|
506
|
-
/* earlier versions of nginx does not allow subrequests
|
507
|
-
to send last_buf themselves */
|
508
|
-
if (r != r->main) {
|
509
|
-
return NGX_OK;
|
510
|
-
}
|
511
|
-
|
512
|
-
#endif
|
513
|
-
|
514
|
-
ctx->eof = 1;
|
515
|
-
|
516
|
-
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
517
|
-
"lua sending last buf of the response body");
|
518
|
-
|
519
|
-
rc = ngx_http_lua_send_special(r, NGX_HTTP_LAST);
|
520
|
-
|
521
|
-
if (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE) {
|
522
|
-
return rc;
|
523
|
-
}
|
524
|
-
|
525
|
-
return NGX_OK;
|
526
|
-
}
|
527
|
-
|
528
|
-
/* in != NULL */
|
529
|
-
|
530
|
-
if (ctx->buffering) {
|
531
|
-
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
532
|
-
"lua buffering output bufs for the HTTP 1.0 request");
|
533
|
-
|
534
|
-
for (cl = ctx->out, ll = &ctx->out; cl; cl = cl->next) {
|
535
|
-
ll = &cl->next;
|
536
|
-
}
|
537
|
-
|
538
|
-
*ll = in;
|
539
|
-
|
540
|
-
return NGX_OK;
|
541
|
-
}
|
542
|
-
|
543
|
-
return ngx_http_lua_output_filter(r, in);
|
544
|
-
}
|
545
|
-
|
546
|
-
|
547
|
-
static ngx_int_t
|
548
|
-
ngx_http_lua_send_special(ngx_http_request_t *r, ngx_uint_t flags)
|
549
|
-
{
|
550
|
-
ngx_int_t rc;
|
551
|
-
ngx_http_request_t *ar; /* active request */
|
552
|
-
|
553
|
-
ar = r->connection->data;
|
554
|
-
|
555
|
-
if (ar != r) {
|
556
|
-
|
557
|
-
/* bypass ngx_http_postpone_filter_module */
|
558
|
-
|
559
|
-
r->connection->data = r;
|
560
|
-
rc = ngx_http_send_special(r, flags);
|
561
|
-
r->connection->data = ar;
|
562
|
-
return rc;
|
563
|
-
}
|
564
|
-
|
565
|
-
return ngx_http_send_special(r, flags);
|
566
|
-
}
|
567
|
-
|
568
|
-
|
569
|
-
static ngx_int_t
|
570
|
-
ngx_http_lua_output_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
571
|
-
{
|
572
|
-
ngx_int_t rc;
|
573
|
-
ngx_http_lua_ctx_t *ctx;
|
574
|
-
ngx_http_request_t *ar; /* active request */
|
575
|
-
|
576
|
-
ar = r->connection->data;
|
577
|
-
|
578
|
-
if (ar != r) {
|
579
|
-
|
580
|
-
/* bypass ngx_http_postpone_filter_module */
|
581
|
-
|
582
|
-
r->connection->data = r;
|
583
|
-
rc = ngx_http_output_filter(r, in);
|
584
|
-
r->connection->data = ar;
|
585
|
-
return rc;
|
586
|
-
}
|
587
|
-
|
588
|
-
rc = ngx_http_output_filter(r, in);
|
589
|
-
|
590
|
-
if (rc == NGX_ERROR) {
|
591
|
-
return NGX_ERROR;
|
592
|
-
}
|
593
|
-
|
594
|
-
ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module);
|
595
|
-
|
596
|
-
#if nginx_version >= 1001004
|
597
|
-
ngx_chain_update_chains(r->pool,
|
598
|
-
#else
|
599
|
-
ngx_chain_update_chains(
|
600
|
-
#endif
|
601
|
-
&ctx->free_bufs, &ctx->busy_bufs, &in,
|
602
|
-
(ngx_buf_tag_t) &ngx_http_lua_module);
|
603
|
-
|
604
|
-
return rc;
|
605
|
-
}
|
606
|
-
|
607
|
-
|
608
|
-
static ngx_int_t
|
609
|
-
ngx_http_lua_send_http10_headers(ngx_http_request_t *r,
|
610
|
-
ngx_http_lua_ctx_t *ctx)
|
611
|
-
{
|
612
|
-
off_t size;
|
613
|
-
ngx_chain_t *cl;
|
614
|
-
ngx_int_t rc;
|
615
|
-
|
616
|
-
if (r->header_sent) {
|
617
|
-
return NGX_OK;
|
618
|
-
}
|
619
|
-
|
620
|
-
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
621
|
-
"lua sending HTTP 1.0 response headers");
|
622
|
-
|
623
|
-
if (r->header_only) {
|
624
|
-
goto send;
|
625
|
-
}
|
626
|
-
|
627
|
-
if (r->headers_out.content_length == NULL) {
|
628
|
-
for (size = 0, cl = ctx->out; cl; cl = cl->next) {
|
629
|
-
size += ngx_buf_size(cl->buf);
|
630
|
-
}
|
631
|
-
|
632
|
-
r->headers_out.content_length_n = size;
|
633
|
-
|
634
|
-
if (r->headers_out.content_length) {
|
635
|
-
r->headers_out.content_length->hash = 0;
|
636
|
-
}
|
637
|
-
}
|
638
|
-
|
639
|
-
send:
|
640
|
-
|
641
|
-
rc = ngx_http_send_header(r);
|
642
|
-
return rc;
|
643
|
-
}
|
644
|
-
|
645
|
-
|
646
|
-
static void
|
647
|
-
ngx_http_lua_init_registry(lua_State *L, ngx_log_t *log)
|
648
|
-
{
|
649
|
-
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, log, 0,
|
650
|
-
"lua initializing lua registry");
|
651
|
-
|
652
|
-
/* {{{ register a table to anchor lua coroutines reliably:
|
653
|
-
* {([int]ref) = [cort]} */
|
654
|
-
lua_pushlightuserdata(L, &ngx_http_lua_coroutines_key);
|
655
|
-
lua_createtable(L, 0, 32 /* nrec */);
|
656
|
-
lua_rawset(L, LUA_REGISTRYINDEX);
|
657
|
-
/* }}} */
|
658
|
-
|
659
|
-
/* create the registry entry for the Lua request ctx data table */
|
660
|
-
lua_pushliteral(L, ngx_http_lua_ctx_tables_key);
|
661
|
-
lua_createtable(L, 0, 32 /* nrec */);
|
662
|
-
lua_rawset(L, LUA_REGISTRYINDEX);
|
663
|
-
|
664
|
-
/* create the registry entry for the Lua socket connection pool table */
|
665
|
-
lua_pushlightuserdata(L, &ngx_http_lua_socket_pool_key);
|
666
|
-
lua_createtable(L, 0, 8 /* nrec */);
|
667
|
-
lua_rawset(L, LUA_REGISTRYINDEX);
|
668
|
-
|
669
|
-
#if (NGX_PCRE)
|
670
|
-
/* create the registry entry for the Lua precompiled regex object cache */
|
671
|
-
lua_pushlightuserdata(L, &ngx_http_lua_regex_cache_key);
|
672
|
-
lua_createtable(L, 0, 16 /* nrec */);
|
673
|
-
lua_rawset(L, LUA_REGISTRYINDEX);
|
674
|
-
#endif
|
675
|
-
|
676
|
-
/* {{{ register table to cache user code:
|
677
|
-
* { [(string)cache_key] = <code closure> } */
|
678
|
-
lua_pushlightuserdata(L, &ngx_http_lua_code_cache_key);
|
679
|
-
lua_createtable(L, 0, 8 /* nrec */);
|
680
|
-
lua_rawset(L, LUA_REGISTRYINDEX);
|
681
|
-
/* }}} */
|
682
|
-
}
|
683
|
-
|
684
|
-
|
685
|
-
static void
|
686
|
-
ngx_http_lua_init_globals(lua_State *L, ngx_cycle_t *cycle,
|
687
|
-
ngx_http_lua_main_conf_t *lmcf, ngx_log_t *log)
|
688
|
-
{
|
689
|
-
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, log, 0,
|
690
|
-
"lua initializing lua globals");
|
691
|
-
|
692
|
-
lua_pushlightuserdata(L, cycle);
|
693
|
-
lua_setglobal(L, "__ngx_cycle");
|
694
|
-
|
695
|
-
#if defined(NDK) && NDK
|
696
|
-
ngx_http_lua_inject_ndk_api(L);
|
697
|
-
#endif /* defined(NDK) && NDK */
|
698
|
-
|
699
|
-
ngx_http_lua_inject_ngx_api(L, lmcf, log);
|
700
|
-
}
|
701
|
-
|
702
|
-
|
703
|
-
static void
|
704
|
-
ngx_http_lua_inject_ngx_api(lua_State *L, ngx_http_lua_main_conf_t *lmcf,
|
705
|
-
ngx_log_t *log)
|
706
|
-
{
|
707
|
-
lua_createtable(L, 0 /* narr */, 99 /* nrec */); /* ngx.* */
|
708
|
-
|
709
|
-
lua_pushcfunction(L, ngx_http_lua_get_raw_phase_context);
|
710
|
-
lua_setfield(L, -2, "_phase_ctx");
|
711
|
-
|
712
|
-
ngx_http_lua_inject_arg_api(L);
|
713
|
-
|
714
|
-
ngx_http_lua_inject_http_consts(L);
|
715
|
-
ngx_http_lua_inject_core_consts(L);
|
716
|
-
|
717
|
-
ngx_http_lua_inject_log_api(L);
|
718
|
-
ngx_http_lua_inject_output_api(L);
|
719
|
-
ngx_http_lua_inject_time_api(L);
|
720
|
-
ngx_http_lua_inject_string_api(L);
|
721
|
-
ngx_http_lua_inject_control_api(log, L);
|
722
|
-
ngx_http_lua_inject_subrequest_api(L);
|
723
|
-
ngx_http_lua_inject_sleep_api(L);
|
724
|
-
ngx_http_lua_inject_phase_api(L);
|
725
|
-
|
726
|
-
#if (NGX_PCRE)
|
727
|
-
ngx_http_lua_inject_regex_api(L);
|
728
|
-
#endif
|
729
|
-
|
730
|
-
ngx_http_lua_inject_req_api(log, L);
|
731
|
-
ngx_http_lua_inject_resp_header_api(L);
|
732
|
-
ngx_http_lua_create_headers_metatable(log, L);
|
733
|
-
ngx_http_lua_inject_variable_api(L);
|
734
|
-
ngx_http_lua_inject_shdict_api(lmcf, L);
|
735
|
-
ngx_http_lua_inject_socket_tcp_api(log, L);
|
736
|
-
ngx_http_lua_inject_socket_udp_api(log, L);
|
737
|
-
ngx_http_lua_inject_uthread_api(log, L);
|
738
|
-
ngx_http_lua_inject_timer_api(L);
|
739
|
-
ngx_http_lua_inject_config_api(L);
|
740
|
-
ngx_http_lua_inject_worker_api(L);
|
741
|
-
|
742
|
-
ngx_http_lua_inject_misc_api(L);
|
743
|
-
|
744
|
-
lua_getglobal(L, "package"); /* ngx package */
|
745
|
-
lua_getfield(L, -1, "loaded"); /* ngx package loaded */
|
746
|
-
lua_pushvalue(L, -3); /* ngx package loaded ngx */
|
747
|
-
lua_setfield(L, -2, "ngx"); /* ngx package loaded */
|
748
|
-
lua_pop(L, 2);
|
749
|
-
|
750
|
-
lua_setglobal(L, "ngx");
|
751
|
-
|
752
|
-
ngx_http_lua_inject_coroutine_api(log, L);
|
753
|
-
}
|
754
|
-
|
755
|
-
|
756
|
-
void
|
757
|
-
ngx_http_lua_discard_bufs(ngx_pool_t *pool, ngx_chain_t *in)
|
758
|
-
{
|
759
|
-
ngx_chain_t *cl;
|
760
|
-
|
761
|
-
for (cl = in; cl; cl = cl->next) {
|
762
|
-
cl->buf->pos = cl->buf->last;
|
763
|
-
cl->buf->file_pos = cl->buf->file_last;
|
764
|
-
}
|
765
|
-
}
|
766
|
-
|
767
|
-
|
768
|
-
ngx_int_t
|
769
|
-
ngx_http_lua_add_copy_chain(ngx_http_request_t *r, ngx_http_lua_ctx_t *ctx,
|
770
|
-
ngx_chain_t ***plast, ngx_chain_t *in, ngx_int_t *eof)
|
771
|
-
{
|
772
|
-
ngx_chain_t *cl;
|
773
|
-
size_t len;
|
774
|
-
ngx_buf_t *b;
|
775
|
-
|
776
|
-
len = 0;
|
777
|
-
*eof = 0;
|
778
|
-
|
779
|
-
for (cl = in; cl; cl = cl->next) {
|
780
|
-
if (ngx_buf_in_memory(cl->buf)) {
|
781
|
-
len += cl->buf->last - cl->buf->pos;
|
782
|
-
}
|
783
|
-
|
784
|
-
if (cl->buf->last_in_chain || cl->buf->last_buf) {
|
785
|
-
*eof = 1;
|
786
|
-
}
|
787
|
-
}
|
788
|
-
|
789
|
-
if (len == 0) {
|
790
|
-
return NGX_OK;
|
791
|
-
}
|
792
|
-
|
793
|
-
cl = ngx_http_lua_chain_get_free_buf(r->connection->log, r->pool,
|
794
|
-
&ctx->free_bufs, len);
|
795
|
-
if (cl == NULL) {
|
796
|
-
return NGX_ERROR;
|
797
|
-
}
|
798
|
-
|
799
|
-
dd("chains get free buf: %d == %d", (int) (cl->buf->end - cl->buf->start),
|
800
|
-
(int) len);
|
801
|
-
|
802
|
-
b = cl->buf;
|
803
|
-
|
804
|
-
while (in) {
|
805
|
-
if (ngx_buf_in_memory(in->buf)) {
|
806
|
-
b->last = ngx_copy(b->last, in->buf->pos,
|
807
|
-
in->buf->last - in->buf->pos);
|
808
|
-
}
|
809
|
-
|
810
|
-
in = in->next;
|
811
|
-
}
|
812
|
-
|
813
|
-
**plast = cl;
|
814
|
-
*plast = &cl->next;
|
815
|
-
|
816
|
-
return NGX_OK;
|
817
|
-
}
|
818
|
-
|
819
|
-
|
820
|
-
void
|
821
|
-
ngx_http_lua_reset_ctx(ngx_http_request_t *r, lua_State *L,
|
822
|
-
ngx_http_lua_ctx_t *ctx)
|
823
|
-
{
|
824
|
-
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
825
|
-
"lua reset ctx");
|
826
|
-
|
827
|
-
ngx_http_lua_finalize_threads(r, ctx, L);
|
828
|
-
|
829
|
-
#if 0
|
830
|
-
if (ctx->user_co_ctx) {
|
831
|
-
/* no way to destroy a list but clean up the whole pool */
|
832
|
-
ctx->user_co_ctx = NULL;
|
833
|
-
}
|
834
|
-
#endif
|
835
|
-
|
836
|
-
ngx_memzero(&ctx->entry_co_ctx, sizeof(ngx_http_lua_co_ctx_t));
|
837
|
-
|
838
|
-
ctx->entry_co_ctx.co_ref = LUA_NOREF;
|
839
|
-
|
840
|
-
ctx->entered_rewrite_phase = 0;
|
841
|
-
ctx->entered_access_phase = 0;
|
842
|
-
ctx->entered_content_phase = 0;
|
843
|
-
|
844
|
-
ctx->exit_code = 0;
|
845
|
-
ctx->exited = 0;
|
846
|
-
ctx->resume_handler = ngx_http_lua_wev_handler;
|
847
|
-
|
848
|
-
ngx_str_null(&ctx->exec_uri);
|
849
|
-
ngx_str_null(&ctx->exec_args);
|
850
|
-
|
851
|
-
ctx->co_op = 0;
|
852
|
-
}
|
853
|
-
|
854
|
-
|
855
|
-
/* post read callback for rewrite and access phases */
|
856
|
-
void
|
857
|
-
ngx_http_lua_generic_phase_post_read(ngx_http_request_t *r)
|
858
|
-
{
|
859
|
-
ngx_http_lua_ctx_t *ctx;
|
860
|
-
|
861
|
-
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
862
|
-
"lua post read for rewrite/access phases");
|
863
|
-
|
864
|
-
ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module);
|
865
|
-
|
866
|
-
ctx->read_body_done = 1;
|
867
|
-
|
868
|
-
#if defined(nginx_version) && nginx_version >= 8011
|
869
|
-
r->main->count--;
|
870
|
-
#endif
|
871
|
-
|
872
|
-
if (ctx->waiting_more_body) {
|
873
|
-
ctx->waiting_more_body = 0;
|
874
|
-
ngx_http_core_run_phases(r);
|
875
|
-
}
|
876
|
-
}
|
877
|
-
|
878
|
-
|
879
|
-
void
|
880
|
-
ngx_http_lua_request_cleanup_handler(void *data)
|
881
|
-
{
|
882
|
-
ngx_http_lua_ctx_t *ctx = data;
|
883
|
-
|
884
|
-
ngx_http_lua_request_cleanup(ctx, 0 /* forcible */);
|
885
|
-
}
|
886
|
-
|
887
|
-
|
888
|
-
void
|
889
|
-
ngx_http_lua_request_cleanup(ngx_http_lua_ctx_t *ctx, int forcible)
|
890
|
-
{
|
891
|
-
lua_State *L;
|
892
|
-
ngx_http_request_t *r;
|
893
|
-
ngx_http_lua_main_conf_t *lmcf;
|
894
|
-
|
895
|
-
r = ctx->request;
|
896
|
-
|
897
|
-
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
898
|
-
"lua request cleanup: forcible=%d", forcible);
|
899
|
-
|
900
|
-
/* force coroutine handling the request quit */
|
901
|
-
if (ctx == NULL) {
|
902
|
-
dd("ctx is NULL");
|
903
|
-
return;
|
904
|
-
}
|
905
|
-
|
906
|
-
if (ctx->cleanup) {
|
907
|
-
*ctx->cleanup = NULL;
|
908
|
-
ctx->cleanup = NULL;
|
909
|
-
}
|
910
|
-
|
911
|
-
lmcf = ngx_http_get_module_main_conf(r, ngx_http_lua_module);
|
912
|
-
|
913
|
-
#if 1
|
914
|
-
if (r->connection->fd == -1) {
|
915
|
-
/* being a fake request */
|
916
|
-
lmcf->running_timers--;
|
917
|
-
}
|
918
|
-
#endif
|
919
|
-
|
920
|
-
L = ngx_http_lua_get_lua_vm(r, ctx);
|
921
|
-
|
922
|
-
ngx_http_lua_finalize_threads(r, ctx, L);
|
923
|
-
}
|
924
|
-
|
925
|
-
|
926
|
-
/*
|
927
|
-
* description:
|
928
|
-
* run a Lua coroutine specified by ctx->cur_co_ctx->co
|
929
|
-
* return value:
|
930
|
-
* NGX_AGAIN: I/O interruption: r->main->count intact
|
931
|
-
* NGX_DONE: I/O interruption: r->main->count already incremented by 1
|
932
|
-
* NGX_ERROR: error
|
933
|
-
* >= 200 HTTP status code
|
934
|
-
*/
|
935
|
-
ngx_int_t
|
936
|
-
ngx_http_lua_run_thread(lua_State *L, ngx_http_request_t *r,
|
937
|
-
ngx_http_lua_ctx_t *ctx, volatile int nrets)
|
938
|
-
{
|
939
|
-
ngx_http_lua_co_ctx_t *next_coctx, *parent_coctx, *orig_coctx;
|
940
|
-
int rv, success = 1;
|
941
|
-
lua_State *next_co;
|
942
|
-
lua_State *old_co;
|
943
|
-
const char *err, *msg, *trace;
|
944
|
-
ngx_int_t rc;
|
945
|
-
#if (NGX_PCRE)
|
946
|
-
ngx_pool_t *old_pool = NULL;
|
947
|
-
#endif
|
948
|
-
|
949
|
-
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
950
|
-
"lua run thread, top:%d c:%ud", lua_gettop(L),
|
951
|
-
r->main->count);
|
952
|
-
|
953
|
-
/* set Lua VM panic handler */
|
954
|
-
lua_atpanic(L, ngx_http_lua_atpanic);
|
955
|
-
|
956
|
-
dd("ctx = %p", ctx);
|
957
|
-
|
958
|
-
NGX_LUA_EXCEPTION_TRY {
|
959
|
-
|
960
|
-
if (ctx->cur_co_ctx->thread_spawn_yielded) {
|
961
|
-
ngx_http_lua_probe_info("thread spawn yielded");
|
962
|
-
|
963
|
-
ctx->cur_co_ctx->thread_spawn_yielded = 0;
|
964
|
-
nrets = 1;
|
965
|
-
}
|
966
|
-
|
967
|
-
for ( ;; ) {
|
968
|
-
|
969
|
-
dd("calling lua_resume: vm %p, nret %d", ctx->cur_co_ctx->co,
|
970
|
-
(int) nrets);
|
971
|
-
|
972
|
-
#if (NGX_PCRE)
|
973
|
-
/* XXX: work-around to nginx regex subsystem */
|
974
|
-
old_pool = ngx_http_lua_pcre_malloc_init(r->pool);
|
975
|
-
#endif
|
976
|
-
|
977
|
-
/* run code */
|
978
|
-
dd("ctx: %p", ctx);
|
979
|
-
dd("cur co: %p", ctx->cur_co_ctx->co);
|
980
|
-
dd("cur co status: %d", ctx->cur_co_ctx->co_status);
|
981
|
-
|
982
|
-
orig_coctx = ctx->cur_co_ctx;
|
983
|
-
|
984
|
-
#ifdef NGX_LUA_USE_ASSERT
|
985
|
-
dd("%p: saved co top: %d, nrets: %d, true top: %d",
|
986
|
-
orig_coctx->co,
|
987
|
-
(int) orig_coctx->co_top, (int) nrets,
|
988
|
-
(int) lua_gettop(orig_coctx->co));
|
989
|
-
#endif
|
990
|
-
|
991
|
-
#if DDEBUG
|
992
|
-
if (lua_gettop(orig_coctx->co) > 0) {
|
993
|
-
dd("top elem: %s", luaL_typename(orig_coctx->co, -1));
|
994
|
-
}
|
995
|
-
#endif
|
996
|
-
|
997
|
-
ngx_http_lua_assert(orig_coctx->co_top + nrets
|
998
|
-
== lua_gettop(orig_coctx->co));
|
999
|
-
|
1000
|
-
rv = lua_resume(orig_coctx->co, nrets);
|
1001
|
-
|
1002
|
-
#if (NGX_PCRE)
|
1003
|
-
/* XXX: work-around to nginx regex subsystem */
|
1004
|
-
ngx_http_lua_pcre_malloc_done(old_pool);
|
1005
|
-
#endif
|
1006
|
-
|
1007
|
-
#if 0
|
1008
|
-
/* test the longjmp thing */
|
1009
|
-
if (rand() % 2 == 0) {
|
1010
|
-
NGX_LUA_EXCEPTION_THROW(1);
|
1011
|
-
}
|
1012
|
-
#endif
|
1013
|
-
|
1014
|
-
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
1015
|
-
"lua resume returned %d", rv);
|
1016
|
-
|
1017
|
-
switch (rv) {
|
1018
|
-
case LUA_YIELD:
|
1019
|
-
/* yielded, let event handler do the rest job */
|
1020
|
-
/* FIXME: add io cmd dispatcher here */
|
1021
|
-
|
1022
|
-
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
1023
|
-
"lua thread yielded");
|
1024
|
-
|
1025
|
-
#ifdef NGX_LUA_USE_ASSERT
|
1026
|
-
dd("%p: saving curr top after yield: %d (co-op: %d)",
|
1027
|
-
orig_coctx->co,
|
1028
|
-
(int) lua_gettop(orig_coctx->co), (int) ctx->co_op);
|
1029
|
-
orig_coctx->co_top = lua_gettop(orig_coctx->co);
|
1030
|
-
#endif
|
1031
|
-
|
1032
|
-
if (r->uri_changed) {
|
1033
|
-
return ngx_http_lua_handle_rewrite_jump(L, r, ctx);
|
1034
|
-
}
|
1035
|
-
|
1036
|
-
if (ctx->exited) {
|
1037
|
-
return ngx_http_lua_handle_exit(L, r, ctx);
|
1038
|
-
}
|
1039
|
-
|
1040
|
-
if (ctx->exec_uri.len) {
|
1041
|
-
return ngx_http_lua_handle_exec(L, r, ctx);
|
1042
|
-
}
|
1043
|
-
|
1044
|
-
/*
|
1045
|
-
* check if coroutine.resume or coroutine.yield called
|
1046
|
-
* lua_yield()
|
1047
|
-
*/
|
1048
|
-
switch(ctx->co_op) {
|
1049
|
-
case NGX_HTTP_LUA_USER_CORO_NOP:
|
1050
|
-
dd("hit! it is the API yield");
|
1051
|
-
|
1052
|
-
ngx_http_lua_assert(lua_gettop(ctx->cur_co_ctx->co) == 0);
|
1053
|
-
|
1054
|
-
ctx->cur_co_ctx = NULL;
|
1055
|
-
|
1056
|
-
return NGX_AGAIN;
|
1057
|
-
|
1058
|
-
case NGX_HTTP_LUA_USER_THREAD_RESUME:
|
1059
|
-
|
1060
|
-
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
1061
|
-
"lua user thread resume");
|
1062
|
-
|
1063
|
-
ctx->co_op = NGX_HTTP_LUA_USER_CORO_NOP;
|
1064
|
-
nrets = lua_gettop(ctx->cur_co_ctx->co) - 1;
|
1065
|
-
dd("nrets = %d", nrets);
|
1066
|
-
|
1067
|
-
#ifdef NGX_LUA_USE_ASSERT
|
1068
|
-
/* ignore the return value (the thread) already pushed */
|
1069
|
-
orig_coctx->co_top--;
|
1070
|
-
#endif
|
1071
|
-
|
1072
|
-
break;
|
1073
|
-
|
1074
|
-
case NGX_HTTP_LUA_USER_CORO_RESUME:
|
1075
|
-
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
1076
|
-
"lua coroutine: resume");
|
1077
|
-
|
1078
|
-
/*
|
1079
|
-
* the target coroutine lies at the base of the
|
1080
|
-
* parent's stack
|
1081
|
-
*/
|
1082
|
-
ctx->co_op = NGX_HTTP_LUA_USER_CORO_NOP;
|
1083
|
-
|
1084
|
-
old_co = ctx->cur_co_ctx->parent_co_ctx->co;
|
1085
|
-
|
1086
|
-
nrets = lua_gettop(old_co);
|
1087
|
-
if (nrets) {
|
1088
|
-
dd("moving %d return values to parent", nrets);
|
1089
|
-
lua_xmove(old_co, ctx->cur_co_ctx->co, nrets);
|
1090
|
-
|
1091
|
-
#ifdef NGX_LUA_USE_ASSERT
|
1092
|
-
ctx->cur_co_ctx->parent_co_ctx->co_top -= nrets;
|
1093
|
-
#endif
|
1094
|
-
}
|
1095
|
-
|
1096
|
-
break;
|
1097
|
-
|
1098
|
-
default:
|
1099
|
-
/* ctx->co_op == NGX_HTTP_LUA_USER_CORO_YIELD */
|
1100
|
-
|
1101
|
-
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
1102
|
-
"lua coroutine: yield");
|
1103
|
-
|
1104
|
-
ctx->co_op = NGX_HTTP_LUA_USER_CORO_NOP;
|
1105
|
-
|
1106
|
-
if (ngx_http_lua_is_thread(ctx)) {
|
1107
|
-
ngx_http_lua_probe_thread_yield(r, ctx->cur_co_ctx->co);
|
1108
|
-
|
1109
|
-
/* discard any return values from user
|
1110
|
-
* coroutine.yield()'s arguments */
|
1111
|
-
lua_settop(ctx->cur_co_ctx->co, 0);
|
1112
|
-
|
1113
|
-
#ifdef NGX_LUA_USE_ASSERT
|
1114
|
-
ctx->cur_co_ctx->co_top = 0;
|
1115
|
-
#endif
|
1116
|
-
|
1117
|
-
ngx_http_lua_probe_info("set co running");
|
1118
|
-
ctx->cur_co_ctx->co_status = NGX_HTTP_LUA_CO_RUNNING;
|
1119
|
-
|
1120
|
-
if (ctx->posted_threads) {
|
1121
|
-
ngx_http_lua_post_thread(r, ctx, ctx->cur_co_ctx);
|
1122
|
-
ctx->cur_co_ctx = NULL;
|
1123
|
-
return NGX_AGAIN;
|
1124
|
-
}
|
1125
|
-
|
1126
|
-
/* no pending threads, so resume the thread
|
1127
|
-
* immediately */
|
1128
|
-
|
1129
|
-
nrets = 0;
|
1130
|
-
continue;
|
1131
|
-
}
|
1132
|
-
|
1133
|
-
/* being a user coroutine that has a parent */
|
1134
|
-
|
1135
|
-
nrets = lua_gettop(ctx->cur_co_ctx->co);
|
1136
|
-
|
1137
|
-
next_coctx = ctx->cur_co_ctx->parent_co_ctx;
|
1138
|
-
next_co = next_coctx->co;
|
1139
|
-
|
1140
|
-
/*
|
1141
|
-
* prepare return values for coroutine.resume
|
1142
|
-
* (true plus any retvals)
|
1143
|
-
*/
|
1144
|
-
lua_pushboolean(next_co, 1);
|
1145
|
-
|
1146
|
-
if (nrets) {
|
1147
|
-
dd("moving %d return values to next co", nrets);
|
1148
|
-
lua_xmove(ctx->cur_co_ctx->co, next_co, nrets);
|
1149
|
-
#ifdef NGX_LUA_USE_ASSERT
|
1150
|
-
ctx->cur_co_ctx->co_top -= nrets;
|
1151
|
-
#endif
|
1152
|
-
}
|
1153
|
-
|
1154
|
-
nrets++; /* add the true boolean value */
|
1155
|
-
|
1156
|
-
ctx->cur_co_ctx = next_coctx;
|
1157
|
-
|
1158
|
-
break;
|
1159
|
-
}
|
1160
|
-
|
1161
|
-
/* try resuming on the new coroutine again */
|
1162
|
-
continue;
|
1163
|
-
|
1164
|
-
case 0:
|
1165
|
-
|
1166
|
-
ngx_http_lua_cleanup_pending_operation(ctx->cur_co_ctx);
|
1167
|
-
|
1168
|
-
ngx_http_lua_probe_coroutine_done(r, ctx->cur_co_ctx->co, 1);
|
1169
|
-
|
1170
|
-
ctx->cur_co_ctx->co_status = NGX_HTTP_LUA_CO_DEAD;
|
1171
|
-
|
1172
|
-
if (ctx->cur_co_ctx->zombie_child_threads) {
|
1173
|
-
ngx_http_lua_cleanup_zombie_child_uthreads(r, L, ctx,
|
1174
|
-
ctx->cur_co_ctx);
|
1175
|
-
}
|
1176
|
-
|
1177
|
-
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
1178
|
-
"lua light thread ended normally");
|
1179
|
-
|
1180
|
-
if (ngx_http_lua_is_entry_thread(ctx)) {
|
1181
|
-
|
1182
|
-
lua_settop(L, 0);
|
1183
|
-
|
1184
|
-
ngx_http_lua_del_thread(r, L, ctx, ctx->cur_co_ctx);
|
1185
|
-
|
1186
|
-
dd("uthreads: %d", (int) ctx->uthreads);
|
1187
|
-
|
1188
|
-
if (ctx->uthreads) {
|
1189
|
-
|
1190
|
-
ctx->cur_co_ctx = NULL;
|
1191
|
-
return NGX_AGAIN;
|
1192
|
-
}
|
1193
|
-
|
1194
|
-
/* all user threads terminated already */
|
1195
|
-
goto done;
|
1196
|
-
}
|
1197
|
-
|
1198
|
-
if (ctx->cur_co_ctx->is_uthread) {
|
1199
|
-
/* being a user thread */
|
1200
|
-
|
1201
|
-
lua_settop(L, 0);
|
1202
|
-
|
1203
|
-
parent_coctx = ctx->cur_co_ctx->parent_co_ctx;
|
1204
|
-
|
1205
|
-
if (ngx_http_lua_coroutine_alive(parent_coctx)) {
|
1206
|
-
if (ctx->cur_co_ctx->waited_by_parent) {
|
1207
|
-
ngx_http_lua_probe_info("parent already waiting");
|
1208
|
-
ctx->cur_co_ctx->waited_by_parent = 0;
|
1209
|
-
success = 1;
|
1210
|
-
goto user_co_done;
|
1211
|
-
}
|
1212
|
-
|
1213
|
-
ngx_http_lua_probe_info("parent still alive");
|
1214
|
-
|
1215
|
-
if (ngx_http_lua_post_zombie_thread(r, parent_coctx,
|
1216
|
-
ctx->cur_co_ctx)
|
1217
|
-
!= NGX_OK)
|
1218
|
-
{
|
1219
|
-
return NGX_ERROR;
|
1220
|
-
}
|
1221
|
-
|
1222
|
-
lua_pushboolean(ctx->cur_co_ctx->co, 1);
|
1223
|
-
lua_insert(ctx->cur_co_ctx->co, 1);
|
1224
|
-
|
1225
|
-
ctx->cur_co_ctx->co_status = NGX_HTTP_LUA_CO_ZOMBIE;
|
1226
|
-
ctx->cur_co_ctx = NULL;
|
1227
|
-
return NGX_AGAIN;
|
1228
|
-
}
|
1229
|
-
|
1230
|
-
ngx_http_lua_del_thread(r, L, ctx, ctx->cur_co_ctx);
|
1231
|
-
ctx->uthreads--;
|
1232
|
-
|
1233
|
-
if (ctx->uthreads == 0) {
|
1234
|
-
if (ngx_http_lua_entry_thread_alive(ctx)) {
|
1235
|
-
ctx->cur_co_ctx = NULL;
|
1236
|
-
return NGX_AGAIN;
|
1237
|
-
}
|
1238
|
-
|
1239
|
-
/* all threads terminated already */
|
1240
|
-
goto done;
|
1241
|
-
}
|
1242
|
-
|
1243
|
-
/* some other user threads still running */
|
1244
|
-
ctx->cur_co_ctx = NULL;
|
1245
|
-
return NGX_AGAIN;
|
1246
|
-
}
|
1247
|
-
|
1248
|
-
/* being a user coroutine that has a parent */
|
1249
|
-
|
1250
|
-
success = 1;
|
1251
|
-
|
1252
|
-
user_co_done:
|
1253
|
-
|
1254
|
-
nrets = lua_gettop(ctx->cur_co_ctx->co);
|
1255
|
-
|
1256
|
-
next_coctx = ctx->cur_co_ctx->parent_co_ctx;
|
1257
|
-
|
1258
|
-
if (next_coctx == NULL) {
|
1259
|
-
/* being a light thread */
|
1260
|
-
goto no_parent;
|
1261
|
-
}
|
1262
|
-
|
1263
|
-
next_co = next_coctx->co;
|
1264
|
-
|
1265
|
-
/*
|
1266
|
-
* ended successful, coroutine.resume returns true plus
|
1267
|
-
* any return values
|
1268
|
-
*/
|
1269
|
-
lua_pushboolean(next_co, success);
|
1270
|
-
|
1271
|
-
if (nrets) {
|
1272
|
-
lua_xmove(ctx->cur_co_ctx->co, next_co, nrets);
|
1273
|
-
}
|
1274
|
-
|
1275
|
-
if (ctx->cur_co_ctx->is_uthread) {
|
1276
|
-
ngx_http_lua_del_thread(r, L, ctx, ctx->cur_co_ctx);
|
1277
|
-
ctx->uthreads--;
|
1278
|
-
}
|
1279
|
-
|
1280
|
-
nrets++;
|
1281
|
-
ctx->cur_co_ctx = next_coctx;
|
1282
|
-
|
1283
|
-
ngx_http_lua_probe_info("set parent running");
|
1284
|
-
|
1285
|
-
next_coctx->co_status = NGX_HTTP_LUA_CO_RUNNING;
|
1286
|
-
|
1287
|
-
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
1288
|
-
"lua coroutine: lua user thread ended normally");
|
1289
|
-
|
1290
|
-
continue;
|
1291
|
-
|
1292
|
-
case LUA_ERRRUN:
|
1293
|
-
err = "runtime error";
|
1294
|
-
break;
|
1295
|
-
|
1296
|
-
case LUA_ERRSYNTAX:
|
1297
|
-
err = "syntax error";
|
1298
|
-
break;
|
1299
|
-
|
1300
|
-
case LUA_ERRMEM:
|
1301
|
-
err = "memory allocation error";
|
1302
|
-
ngx_quit = 1;
|
1303
|
-
break;
|
1304
|
-
|
1305
|
-
case LUA_ERRERR:
|
1306
|
-
err = "error handler error";
|
1307
|
-
break;
|
1308
|
-
|
1309
|
-
default:
|
1310
|
-
err = "unknown error";
|
1311
|
-
break;
|
1312
|
-
}
|
1313
|
-
|
1314
|
-
if (ctx->cur_co_ctx != orig_coctx) {
|
1315
|
-
ctx->cur_co_ctx = orig_coctx;
|
1316
|
-
}
|
1317
|
-
|
1318
|
-
if (lua_isstring(ctx->cur_co_ctx->co, -1)) {
|
1319
|
-
dd("user custom error msg");
|
1320
|
-
msg = lua_tostring(ctx->cur_co_ctx->co, -1);
|
1321
|
-
|
1322
|
-
} else {
|
1323
|
-
msg = "unknown reason";
|
1324
|
-
}
|
1325
|
-
|
1326
|
-
ngx_http_lua_cleanup_pending_operation(ctx->cur_co_ctx);
|
1327
|
-
|
1328
|
-
ngx_http_lua_probe_coroutine_done(r, ctx->cur_co_ctx->co, 0);
|
1329
|
-
|
1330
|
-
ctx->cur_co_ctx->co_status = NGX_HTTP_LUA_CO_DEAD;
|
1331
|
-
|
1332
|
-
ngx_http_lua_thread_traceback(L, ctx->cur_co_ctx->co,
|
1333
|
-
ctx->cur_co_ctx);
|
1334
|
-
trace = lua_tostring(L, -1);
|
1335
|
-
|
1336
|
-
if (ctx->cur_co_ctx->is_uthread) {
|
1337
|
-
|
1338
|
-
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
1339
|
-
"lua user thread aborted: %s: %s\n%s",
|
1340
|
-
err, msg, trace);
|
1341
|
-
|
1342
|
-
lua_settop(L, 0);
|
1343
|
-
|
1344
|
-
parent_coctx = ctx->cur_co_ctx->parent_co_ctx;
|
1345
|
-
|
1346
|
-
if (ngx_http_lua_coroutine_alive(parent_coctx)) {
|
1347
|
-
if (ctx->cur_co_ctx->waited_by_parent) {
|
1348
|
-
ctx->cur_co_ctx->waited_by_parent = 0;
|
1349
|
-
success = 0;
|
1350
|
-
goto user_co_done;
|
1351
|
-
}
|
1352
|
-
|
1353
|
-
if (ngx_http_lua_post_zombie_thread(r, parent_coctx,
|
1354
|
-
ctx->cur_co_ctx)
|
1355
|
-
!= NGX_OK)
|
1356
|
-
{
|
1357
|
-
return NGX_ERROR;
|
1358
|
-
}
|
1359
|
-
|
1360
|
-
lua_pushboolean(ctx->cur_co_ctx->co, 0);
|
1361
|
-
lua_insert(ctx->cur_co_ctx->co, 1);
|
1362
|
-
|
1363
|
-
ctx->cur_co_ctx->co_status = NGX_HTTP_LUA_CO_ZOMBIE;
|
1364
|
-
ctx->cur_co_ctx = NULL;
|
1365
|
-
return NGX_AGAIN;
|
1366
|
-
}
|
1367
|
-
|
1368
|
-
ngx_http_lua_del_thread(r, L, ctx, ctx->cur_co_ctx);
|
1369
|
-
ctx->uthreads--;
|
1370
|
-
|
1371
|
-
if (ctx->uthreads == 0) {
|
1372
|
-
if (ngx_http_lua_entry_thread_alive(ctx)) {
|
1373
|
-
ctx->cur_co_ctx = NULL;
|
1374
|
-
return NGX_AGAIN;
|
1375
|
-
}
|
1376
|
-
|
1377
|
-
/* all threads terminated already */
|
1378
|
-
goto done;
|
1379
|
-
}
|
1380
|
-
|
1381
|
-
/* some other user threads still running */
|
1382
|
-
ctx->cur_co_ctx = NULL;
|
1383
|
-
return NGX_AGAIN;
|
1384
|
-
}
|
1385
|
-
|
1386
|
-
if (ngx_http_lua_is_entry_thread(ctx)) {
|
1387
|
-
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
1388
|
-
"lua entry thread aborted: %s: %s\n%s",
|
1389
|
-
err, msg, trace);
|
1390
|
-
|
1391
|
-
lua_settop(L, 0);
|
1392
|
-
|
1393
|
-
/* being the entry thread aborted */
|
1394
|
-
|
1395
|
-
if (r->filter_finalize) {
|
1396
|
-
ngx_http_set_ctx(r, ctx, ngx_http_lua_module);
|
1397
|
-
}
|
1398
|
-
|
1399
|
-
ngx_http_lua_request_cleanup(ctx, 0);
|
1400
|
-
|
1401
|
-
dd("headers sent? %d", r->header_sent ? 1 : 0);
|
1402
|
-
|
1403
|
-
if (ctx->no_abort) {
|
1404
|
-
ctx->no_abort = 0;
|
1405
|
-
return NGX_ERROR;
|
1406
|
-
}
|
1407
|
-
|
1408
|
-
return r->header_sent ? NGX_ERROR :
|
1409
|
-
NGX_HTTP_INTERNAL_SERVER_ERROR;
|
1410
|
-
}
|
1411
|
-
|
1412
|
-
/* being a user coroutine that has a parent */
|
1413
|
-
|
1414
|
-
next_coctx = ctx->cur_co_ctx->parent_co_ctx;
|
1415
|
-
if (next_coctx == NULL) {
|
1416
|
-
goto no_parent;
|
1417
|
-
}
|
1418
|
-
|
1419
|
-
next_co = next_coctx->co;
|
1420
|
-
|
1421
|
-
ngx_http_lua_probe_info("set parent running");
|
1422
|
-
|
1423
|
-
next_coctx->co_status = NGX_HTTP_LUA_CO_RUNNING;
|
1424
|
-
|
1425
|
-
/*
|
1426
|
-
* ended with error, coroutine.resume returns false plus
|
1427
|
-
* err msg
|
1428
|
-
*/
|
1429
|
-
lua_pushboolean(next_co, 0);
|
1430
|
-
lua_xmove(ctx->cur_co_ctx->co, next_co, 1);
|
1431
|
-
nrets = 2;
|
1432
|
-
|
1433
|
-
ctx->cur_co_ctx = next_coctx;
|
1434
|
-
|
1435
|
-
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
1436
|
-
"lua coroutine: %s: %s\n%s", err, msg, trace);
|
1437
|
-
|
1438
|
-
/* try resuming on the new coroutine again */
|
1439
|
-
continue;
|
1440
|
-
}
|
1441
|
-
|
1442
|
-
} NGX_LUA_EXCEPTION_CATCH {
|
1443
|
-
dd("nginx execution restored");
|
1444
|
-
}
|
1445
|
-
|
1446
|
-
return NGX_ERROR;
|
1447
|
-
|
1448
|
-
no_parent:
|
1449
|
-
|
1450
|
-
lua_settop(L, 0);
|
1451
|
-
|
1452
|
-
ctx->cur_co_ctx->co_status = NGX_HTTP_LUA_CO_DEAD;
|
1453
|
-
|
1454
|
-
if (r->filter_finalize) {
|
1455
|
-
ngx_http_set_ctx(r, ctx, ngx_http_lua_module);
|
1456
|
-
}
|
1457
|
-
|
1458
|
-
ngx_http_lua_request_cleanup(ctx, 0);
|
1459
|
-
|
1460
|
-
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "lua handler aborted: "
|
1461
|
-
"user coroutine has no parent");
|
1462
|
-
|
1463
|
-
return r->header_sent ? NGX_ERROR : NGX_HTTP_INTERNAL_SERVER_ERROR;
|
1464
|
-
|
1465
|
-
done:
|
1466
|
-
|
1467
|
-
if (ctx->entered_content_phase && r->connection->fd != -1) {
|
1468
|
-
rc = ngx_http_lua_send_chain_link(r, ctx,
|
1469
|
-
NULL /* last_buf */);
|
1470
|
-
|
1471
|
-
if (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE) {
|
1472
|
-
return rc;
|
1473
|
-
}
|
1474
|
-
}
|
1475
|
-
|
1476
|
-
return NGX_OK;
|
1477
|
-
}
|
1478
|
-
|
1479
|
-
|
1480
|
-
ngx_int_t
|
1481
|
-
ngx_http_lua_wev_handler(ngx_http_request_t *r)
|
1482
|
-
{
|
1483
|
-
ngx_int_t rc;
|
1484
|
-
ngx_event_t *wev;
|
1485
|
-
ngx_connection_t *c;
|
1486
|
-
ngx_http_lua_ctx_t *ctx;
|
1487
|
-
ngx_http_lua_co_ctx_t *coctx;
|
1488
|
-
ngx_http_core_loc_conf_t *clcf;
|
1489
|
-
|
1490
|
-
ngx_http_lua_socket_tcp_upstream_t *u;
|
1491
|
-
|
1492
|
-
c = r->connection;
|
1493
|
-
wev = c->write;
|
1494
|
-
|
1495
|
-
ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module);
|
1496
|
-
if (ctx == NULL) {
|
1497
|
-
return NGX_ERROR;
|
1498
|
-
}
|
1499
|
-
|
1500
|
-
ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
1501
|
-
"lua run write event handler: timedout:%ud, ready:%ud, "
|
1502
|
-
"writing_raw_req_socket:%ud",
|
1503
|
-
wev->timedout, wev->ready, ctx->writing_raw_req_socket);
|
1504
|
-
|
1505
|
-
clcf = ngx_http_get_module_loc_conf(r->main, ngx_http_core_module);
|
1506
|
-
|
1507
|
-
if (wev->timedout && !ctx->writing_raw_req_socket) {
|
1508
|
-
if (!wev->delayed) {
|
1509
|
-
ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT,
|
1510
|
-
"client timed out");
|
1511
|
-
c->timedout = 1;
|
1512
|
-
|
1513
|
-
goto flush_coros;
|
1514
|
-
}
|
1515
|
-
|
1516
|
-
wev->timedout = 0;
|
1517
|
-
wev->delayed = 0;
|
1518
|
-
|
1519
|
-
if (!wev->ready) {
|
1520
|
-
ngx_add_timer(wev, clcf->send_timeout);
|
1521
|
-
|
1522
|
-
if (ngx_handle_write_event(wev, clcf->send_lowat) != NGX_OK) {
|
1523
|
-
if (ctx->entered_content_phase) {
|
1524
|
-
ngx_http_lua_finalize_request(r, NGX_ERROR);
|
1525
|
-
}
|
1526
|
-
return NGX_ERROR;
|
1527
|
-
}
|
1528
|
-
}
|
1529
|
-
}
|
1530
|
-
|
1531
|
-
if (!wev->ready && !wev->timedout) {
|
1532
|
-
goto useless;
|
1533
|
-
}
|
1534
|
-
|
1535
|
-
if (ctx->writing_raw_req_socket) {
|
1536
|
-
ctx->writing_raw_req_socket = 0;
|
1537
|
-
|
1538
|
-
coctx = ctx->downstream_co_ctx;
|
1539
|
-
if (coctx == NULL) {
|
1540
|
-
return NGX_ERROR;
|
1541
|
-
}
|
1542
|
-
|
1543
|
-
u = coctx->data;
|
1544
|
-
if (u == NULL) {
|
1545
|
-
return NGX_ERROR;
|
1546
|
-
}
|
1547
|
-
|
1548
|
-
u->write_event_handler(r, u);
|
1549
|
-
return NGX_DONE;
|
1550
|
-
}
|
1551
|
-
|
1552
|
-
if (c->buffered & NGX_HTTP_LOWLEVEL_BUFFERED) {
|
1553
|
-
rc = ngx_http_lua_flush_pending_output(r, ctx);
|
1554
|
-
|
1555
|
-
dd("flush pending output returned %d, c->error: %d", (int) rc,
|
1556
|
-
c->error);
|
1557
|
-
|
1558
|
-
if (rc != NGX_ERROR && rc != NGX_OK) {
|
1559
|
-
goto useless;
|
1560
|
-
}
|
1561
|
-
|
1562
|
-
/* when rc == NGX_ERROR, c->error must be set */
|
1563
|
-
}
|
1564
|
-
|
1565
|
-
flush_coros:
|
1566
|
-
|
1567
|
-
dd("ctx->flushing_coros: %d", (int) ctx->flushing_coros);
|
1568
|
-
|
1569
|
-
if (ctx->flushing_coros) {
|
1570
|
-
return ngx_http_lua_process_flushing_coroutines(r, ctx);
|
1571
|
-
}
|
1572
|
-
|
1573
|
-
/* ctx->flushing_coros == 0 */
|
1574
|
-
|
1575
|
-
useless:
|
1576
|
-
|
1577
|
-
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
1578
|
-
"useless lua write event handler");
|
1579
|
-
|
1580
|
-
if (ctx->entered_content_phase) {
|
1581
|
-
return NGX_OK;
|
1582
|
-
}
|
1583
|
-
|
1584
|
-
return NGX_DONE;
|
1585
|
-
}
|
1586
|
-
|
1587
|
-
|
1588
|
-
static ngx_int_t
|
1589
|
-
ngx_http_lua_process_flushing_coroutines(ngx_http_request_t *r,
|
1590
|
-
ngx_http_lua_ctx_t *ctx)
|
1591
|
-
{
|
1592
|
-
ngx_int_t rc, n;
|
1593
|
-
ngx_uint_t i;
|
1594
|
-
ngx_list_part_t *part;
|
1595
|
-
ngx_http_lua_co_ctx_t *coctx;
|
1596
|
-
|
1597
|
-
dd("processing flushing coroutines");
|
1598
|
-
|
1599
|
-
coctx = &ctx->entry_co_ctx;
|
1600
|
-
n = ctx->flushing_coros;
|
1601
|
-
|
1602
|
-
if (coctx->flushing) {
|
1603
|
-
coctx->flushing = 0;
|
1604
|
-
|
1605
|
-
ctx->flushing_coros--;
|
1606
|
-
n--;
|
1607
|
-
ctx->cur_co_ctx = coctx;
|
1608
|
-
|
1609
|
-
rc = ngx_http_lua_flush_resume_helper(r, ctx);
|
1610
|
-
if (rc == NGX_ERROR || rc >= NGX_OK) {
|
1611
|
-
return rc;
|
1612
|
-
}
|
1613
|
-
|
1614
|
-
/* rc == NGX_DONE */
|
1615
|
-
}
|
1616
|
-
|
1617
|
-
if (n) {
|
1618
|
-
|
1619
|
-
if (ctx->user_co_ctx == NULL) {
|
1620
|
-
return NGX_ERROR;
|
1621
|
-
}
|
1622
|
-
|
1623
|
-
part = &ctx->user_co_ctx->part;
|
1624
|
-
coctx = part->elts;
|
1625
|
-
|
1626
|
-
for (i = 0; /* void */; i++) {
|
1627
|
-
|
1628
|
-
if (i >= part->nelts) {
|
1629
|
-
if (part->next == NULL) {
|
1630
|
-
break;
|
1631
|
-
}
|
1632
|
-
|
1633
|
-
part = part->next;
|
1634
|
-
coctx = part->elts;
|
1635
|
-
i = 0;
|
1636
|
-
}
|
1637
|
-
|
1638
|
-
if (coctx[i].flushing) {
|
1639
|
-
coctx[i].flushing = 0;
|
1640
|
-
ctx->cur_co_ctx = &coctx[i];
|
1641
|
-
|
1642
|
-
rc = ngx_http_lua_flush_resume_helper(r, ctx);
|
1643
|
-
if (rc == NGX_ERROR || rc >= NGX_OK) {
|
1644
|
-
return rc;
|
1645
|
-
}
|
1646
|
-
|
1647
|
-
/* rc == NGX_DONE */
|
1648
|
-
|
1649
|
-
ctx->flushing_coros--;
|
1650
|
-
n--;
|
1651
|
-
if (n == 0) {
|
1652
|
-
return NGX_DONE;
|
1653
|
-
}
|
1654
|
-
}
|
1655
|
-
}
|
1656
|
-
}
|
1657
|
-
|
1658
|
-
if (n) {
|
1659
|
-
return NGX_ERROR;
|
1660
|
-
}
|
1661
|
-
|
1662
|
-
return NGX_DONE;
|
1663
|
-
}
|
1664
|
-
|
1665
|
-
|
1666
|
-
static ngx_int_t
|
1667
|
-
ngx_http_lua_flush_pending_output(ngx_http_request_t *r,
|
1668
|
-
ngx_http_lua_ctx_t *ctx)
|
1669
|
-
{
|
1670
|
-
ngx_int_t rc;
|
1671
|
-
ngx_chain_t *cl;
|
1672
|
-
ngx_event_t *wev;
|
1673
|
-
ngx_connection_t *c;
|
1674
|
-
|
1675
|
-
ngx_http_core_loc_conf_t *clcf;
|
1676
|
-
|
1677
|
-
c = r->connection;
|
1678
|
-
wev = c->write;
|
1679
|
-
|
1680
|
-
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
1681
|
-
"lua flushing output: buffered 0x%uxd",
|
1682
|
-
c->buffered);
|
1683
|
-
|
1684
|
-
if (ctx->busy_bufs) {
|
1685
|
-
rc = ngx_http_lua_output_filter(r, NULL);
|
1686
|
-
|
1687
|
-
} else {
|
1688
|
-
cl = ngx_http_lua_get_flush_chain(r, ctx);
|
1689
|
-
if (cl == NULL) {
|
1690
|
-
return NGX_ERROR;
|
1691
|
-
}
|
1692
|
-
|
1693
|
-
rc = ngx_http_lua_output_filter(r, cl);
|
1694
|
-
}
|
1695
|
-
|
1696
|
-
dd("output filter returned %d", (int) rc);
|
1697
|
-
|
1698
|
-
if (rc == NGX_ERROR || rc > NGX_OK) {
|
1699
|
-
return rc;
|
1700
|
-
}
|
1701
|
-
|
1702
|
-
if (c->buffered & NGX_HTTP_LOWLEVEL_BUFFERED) {
|
1703
|
-
|
1704
|
-
clcf = ngx_http_get_module_loc_conf(r->main, ngx_http_core_module);
|
1705
|
-
|
1706
|
-
if (!wev->delayed) {
|
1707
|
-
ngx_add_timer(wev, clcf->send_timeout);
|
1708
|
-
}
|
1709
|
-
|
1710
|
-
if (ngx_handle_write_event(wev, clcf->send_lowat) != NGX_OK) {
|
1711
|
-
if (ctx->entered_content_phase) {
|
1712
|
-
ngx_http_lua_finalize_request(r, NGX_ERROR);
|
1713
|
-
}
|
1714
|
-
|
1715
|
-
return NGX_ERROR;
|
1716
|
-
}
|
1717
|
-
|
1718
|
-
if (ctx->flushing_coros) {
|
1719
|
-
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
1720
|
-
"lua flush still waiting: buffered 0x%uxd",
|
1721
|
-
c->buffered);
|
1722
|
-
|
1723
|
-
return NGX_DONE;
|
1724
|
-
}
|
1725
|
-
|
1726
|
-
} else {
|
1727
|
-
#if 1
|
1728
|
-
if (wev->timer_set && !wev->delayed) {
|
1729
|
-
ngx_del_timer(wev);
|
1730
|
-
}
|
1731
|
-
#endif
|
1732
|
-
}
|
1733
|
-
|
1734
|
-
return NGX_OK;
|
1735
|
-
}
|
1736
|
-
|
1737
|
-
|
1738
|
-
u_char *
|
1739
|
-
ngx_http_lua_digest_hex(u_char *dest, const u_char *buf, int buf_len)
|
1740
|
-
{
|
1741
|
-
ngx_md5_t md5;
|
1742
|
-
u_char md5_buf[MD5_DIGEST_LENGTH];
|
1743
|
-
|
1744
|
-
ngx_md5_init(&md5);
|
1745
|
-
ngx_md5_update(&md5, buf, buf_len);
|
1746
|
-
ngx_md5_final(md5_buf, &md5);
|
1747
|
-
|
1748
|
-
return ngx_hex_dump(dest, md5_buf, sizeof(md5_buf));
|
1749
|
-
}
|
1750
|
-
|
1751
|
-
|
1752
|
-
void
|
1753
|
-
ngx_http_lua_set_multi_value_table(lua_State *L, int index)
|
1754
|
-
{
|
1755
|
-
if (index < 0) {
|
1756
|
-
index = lua_gettop(L) + index + 1;
|
1757
|
-
}
|
1758
|
-
|
1759
|
-
lua_pushvalue(L, -2); /* stack: table key value key */
|
1760
|
-
lua_rawget(L, index);
|
1761
|
-
if (lua_isnil(L, -1)) {
|
1762
|
-
lua_pop(L, 1); /* stack: table key value */
|
1763
|
-
lua_rawset(L, index); /* stack: table */
|
1764
|
-
|
1765
|
-
} else {
|
1766
|
-
if (!lua_istable(L, -1)) {
|
1767
|
-
/* just inserted one value */
|
1768
|
-
lua_createtable(L, 4, 0);
|
1769
|
-
/* stack: table key value value table */
|
1770
|
-
lua_insert(L, -2);
|
1771
|
-
/* stack: table key value table value */
|
1772
|
-
lua_rawseti(L, -2, 1);
|
1773
|
-
/* stack: table key value table */
|
1774
|
-
lua_insert(L, -2);
|
1775
|
-
/* stack: table key table value */
|
1776
|
-
|
1777
|
-
lua_rawseti(L, -2, 2); /* stack: table key table */
|
1778
|
-
|
1779
|
-
lua_rawset(L, index); /* stack: table */
|
1780
|
-
|
1781
|
-
} else {
|
1782
|
-
/* stack: table key value table */
|
1783
|
-
lua_insert(L, -2); /* stack: table key table value */
|
1784
|
-
|
1785
|
-
lua_rawseti(L, -2, lua_objlen(L, -2) + 1);
|
1786
|
-
/* stack: table key table */
|
1787
|
-
lua_pop(L, 2); /* stack: table */
|
1788
|
-
}
|
1789
|
-
}
|
1790
|
-
}
|
1791
|
-
|
1792
|
-
|
1793
|
-
uintptr_t
|
1794
|
-
ngx_http_lua_escape_uri(u_char *dst, u_char *src, size_t size, ngx_uint_t type)
|
1795
|
-
{
|
1796
|
-
ngx_uint_t n;
|
1797
|
-
uint32_t *escape;
|
1798
|
-
static u_char hex[] = "0123456789ABCDEF";
|
1799
|
-
|
1800
|
-
/* " ", "#", "%", "?", %00-%1F, %7F-%FF */
|
1801
|
-
|
1802
|
-
static uint32_t uri[] = {
|
1803
|
-
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
1804
|
-
|
1805
|
-
/* ?>=< ;:98 7654 3210 /.-, +*)( '&%$ #"! */
|
1806
|
-
0xfc00886d, /* 1111 1100 0000 0000 1000 1000 0110 1101 */
|
1807
|
-
|
1808
|
-
/* _^]\ [ZYX WVUT SRQP ONML KJIH GFED CBA@ */
|
1809
|
-
0x78000000, /* 0111 1000 0000 0000 0000 0000 0000 0000 */
|
1810
|
-
|
1811
|
-
/* ~}| {zyx wvut srqp onml kjih gfed cba` */
|
1812
|
-
0xa8000000, /* 1010 1000 0000 0000 0000 0000 0000 0000 */
|
1813
|
-
|
1814
|
-
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
1815
|
-
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
1816
|
-
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
1817
|
-
0xffffffff /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
1818
|
-
};
|
1819
|
-
|
1820
|
-
/* " ", "#", "%", "+", "?", %00-%1F, %7F-%FF */
|
1821
|
-
|
1822
|
-
static uint32_t args[] = {
|
1823
|
-
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
1824
|
-
|
1825
|
-
/* ?>=< ;:98 7654 3210 /.-, +*)( '&%$ #"! */
|
1826
|
-
0x80000829, /* 1000 0000 0000 0000 0000 1000 0010 1001 */
|
1827
|
-
|
1828
|
-
/* _^]\ [ZYX WVUT SRQP ONML KJIH GFED CBA@ */
|
1829
|
-
0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */
|
1830
|
-
|
1831
|
-
/* ~}| {zyx wvut srqp onml kjih gfed cba` */
|
1832
|
-
0x80000000, /* 1000 0000 0000 0000 0000 0000 0000 0000 */
|
1833
|
-
|
1834
|
-
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
1835
|
-
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
1836
|
-
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
1837
|
-
0xffffffff /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
1838
|
-
};
|
1839
|
-
|
1840
|
-
/* " ", "#", """, "%", "'", %00-%1F, %7F-%FF */
|
1841
|
-
|
1842
|
-
static uint32_t html[] = {
|
1843
|
-
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
1844
|
-
|
1845
|
-
/* ?>=< ;:98 7654 3210 /.-, +*)( '&%$ #"! */
|
1846
|
-
0x000000ad, /* 0000 0000 0000 0000 0000 0000 1010 1101 */
|
1847
|
-
|
1848
|
-
/* _^]\ [ZYX WVUT SRQP ONML KJIH GFED CBA@ */
|
1849
|
-
0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */
|
1850
|
-
|
1851
|
-
/* ~}| {zyx wvut srqp onml kjih gfed cba` */
|
1852
|
-
0x80000000, /* 1000 0000 0000 0000 0000 0000 0000 0000 */
|
1853
|
-
|
1854
|
-
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
1855
|
-
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
1856
|
-
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
1857
|
-
0xffffffff /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
1858
|
-
};
|
1859
|
-
|
1860
|
-
/* " ", """, "%", "'", %00-%1F, %7F-%FF */
|
1861
|
-
|
1862
|
-
static uint32_t refresh[] = {
|
1863
|
-
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
1864
|
-
|
1865
|
-
/* ?>=< ;:98 7654 3210 /.-, +*)( '&%$ #"! */
|
1866
|
-
0x00000085, /* 0000 0000 0000 0000 0000 0000 1000 0101 */
|
1867
|
-
|
1868
|
-
/* _^]\ [ZYX WVUT SRQP ONML KJIH GFED CBA@ */
|
1869
|
-
0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */
|
1870
|
-
|
1871
|
-
/* ~}| {zyx wvut srqp onml kjih gfed cba` */
|
1872
|
-
0x80000000, /* 1000 0000 0000 0000 0000 0000 0000 0000 */
|
1873
|
-
|
1874
|
-
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
1875
|
-
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
1876
|
-
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
1877
|
-
0xffffffff /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
1878
|
-
};
|
1879
|
-
|
1880
|
-
/* " ", "%", %00-%1F */
|
1881
|
-
|
1882
|
-
static uint32_t memcached[] = {
|
1883
|
-
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
1884
|
-
|
1885
|
-
/* ?>=< ;:98 7654 3210 /.-, +*)( '&%$ #"! */
|
1886
|
-
0x00000021, /* 0000 0000 0000 0000 0000 0000 0010 0001 */
|
1887
|
-
|
1888
|
-
/* _^]\ [ZYX WVUT SRQP ONML KJIH GFED CBA@ */
|
1889
|
-
0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */
|
1890
|
-
|
1891
|
-
/* ~}| {zyx wvut srqp onml kjih gfed cba` */
|
1892
|
-
0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */
|
1893
|
-
|
1894
|
-
0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */
|
1895
|
-
0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */
|
1896
|
-
0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */
|
1897
|
-
0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */
|
1898
|
-
};
|
1899
|
-
|
1900
|
-
/* mail_auth is the same as memcached */
|
1901
|
-
|
1902
|
-
static uint32_t *map[] =
|
1903
|
-
{ uri, args, html, refresh, memcached, memcached };
|
1904
|
-
|
1905
|
-
|
1906
|
-
escape = map[type];
|
1907
|
-
|
1908
|
-
if (dst == NULL) {
|
1909
|
-
|
1910
|
-
/* find the number of the characters to be escaped */
|
1911
|
-
|
1912
|
-
n = 0;
|
1913
|
-
|
1914
|
-
while (size) {
|
1915
|
-
if (escape[*src >> 5] & (1 << (*src & 0x1f))) {
|
1916
|
-
n++;
|
1917
|
-
}
|
1918
|
-
src++;
|
1919
|
-
size--;
|
1920
|
-
}
|
1921
|
-
|
1922
|
-
return (uintptr_t) n;
|
1923
|
-
}
|
1924
|
-
|
1925
|
-
while (size) {
|
1926
|
-
if (escape[*src >> 5] & (1 << (*src & 0x1f))) {
|
1927
|
-
*dst++ = '%';
|
1928
|
-
*dst++ = hex[*src >> 4];
|
1929
|
-
*dst++ = hex[*src & 0xf];
|
1930
|
-
src++;
|
1931
|
-
|
1932
|
-
} else {
|
1933
|
-
*dst++ = *src++;
|
1934
|
-
}
|
1935
|
-
size--;
|
1936
|
-
}
|
1937
|
-
|
1938
|
-
return (uintptr_t) dst;
|
1939
|
-
}
|
1940
|
-
|
1941
|
-
|
1942
|
-
/* XXX we also decode '+' to ' ' */
|
1943
|
-
void
|
1944
|
-
ngx_http_lua_unescape_uri(u_char **dst, u_char **src, size_t size,
|
1945
|
-
ngx_uint_t type)
|
1946
|
-
{
|
1947
|
-
u_char *d, *s, ch, c, decoded;
|
1948
|
-
enum {
|
1949
|
-
sw_usual = 0,
|
1950
|
-
sw_quoted,
|
1951
|
-
sw_quoted_second
|
1952
|
-
} state;
|
1953
|
-
|
1954
|
-
d = *dst;
|
1955
|
-
s = *src;
|
1956
|
-
|
1957
|
-
state = 0;
|
1958
|
-
decoded = 0;
|
1959
|
-
|
1960
|
-
while (size--) {
|
1961
|
-
|
1962
|
-
ch = *s++;
|
1963
|
-
|
1964
|
-
switch (state) {
|
1965
|
-
case sw_usual:
|
1966
|
-
if (ch == '?'
|
1967
|
-
&& (type & (NGX_UNESCAPE_URI|NGX_UNESCAPE_REDIRECT)))
|
1968
|
-
{
|
1969
|
-
*d++ = ch;
|
1970
|
-
goto done;
|
1971
|
-
}
|
1972
|
-
|
1973
|
-
if (ch == '%') {
|
1974
|
-
state = sw_quoted;
|
1975
|
-
break;
|
1976
|
-
}
|
1977
|
-
|
1978
|
-
if (ch == '+') {
|
1979
|
-
*d++ = ' ';
|
1980
|
-
break;
|
1981
|
-
}
|
1982
|
-
|
1983
|
-
*d++ = ch;
|
1984
|
-
break;
|
1985
|
-
|
1986
|
-
case sw_quoted:
|
1987
|
-
|
1988
|
-
if (ch >= '0' && ch <= '9') {
|
1989
|
-
decoded = (u_char) (ch - '0');
|
1990
|
-
state = sw_quoted_second;
|
1991
|
-
break;
|
1992
|
-
}
|
1993
|
-
|
1994
|
-
c = (u_char) (ch | 0x20);
|
1995
|
-
if (c >= 'a' && c <= 'f') {
|
1996
|
-
decoded = (u_char) (c - 'a' + 10);
|
1997
|
-
state = sw_quoted_second;
|
1998
|
-
break;
|
1999
|
-
}
|
2000
|
-
|
2001
|
-
/* the invalid quoted character */
|
2002
|
-
|
2003
|
-
state = sw_usual;
|
2004
|
-
|
2005
|
-
*d++ = ch;
|
2006
|
-
|
2007
|
-
break;
|
2008
|
-
|
2009
|
-
case sw_quoted_second:
|
2010
|
-
|
2011
|
-
state = sw_usual;
|
2012
|
-
|
2013
|
-
if (ch >= '0' && ch <= '9') {
|
2014
|
-
ch = (u_char) ((decoded << 4) + ch - '0');
|
2015
|
-
|
2016
|
-
if (type & NGX_UNESCAPE_REDIRECT) {
|
2017
|
-
if (ch > '%' && ch < 0x7f) {
|
2018
|
-
*d++ = ch;
|
2019
|
-
break;
|
2020
|
-
}
|
2021
|
-
|
2022
|
-
*d++ = '%'; *d++ = *(s - 2); *d++ = *(s - 1);
|
2023
|
-
break;
|
2024
|
-
}
|
2025
|
-
|
2026
|
-
*d++ = ch;
|
2027
|
-
|
2028
|
-
break;
|
2029
|
-
}
|
2030
|
-
|
2031
|
-
c = (u_char) (ch | 0x20);
|
2032
|
-
if (c >= 'a' && c <= 'f') {
|
2033
|
-
ch = (u_char) ((decoded << 4) + c - 'a' + 10);
|
2034
|
-
|
2035
|
-
if (type & NGX_UNESCAPE_URI) {
|
2036
|
-
if (ch == '?') {
|
2037
|
-
*d++ = ch;
|
2038
|
-
goto done;
|
2039
|
-
}
|
2040
|
-
|
2041
|
-
*d++ = ch;
|
2042
|
-
break;
|
2043
|
-
}
|
2044
|
-
|
2045
|
-
if (type & NGX_UNESCAPE_REDIRECT) {
|
2046
|
-
if (ch == '?') {
|
2047
|
-
*d++ = ch;
|
2048
|
-
goto done;
|
2049
|
-
}
|
2050
|
-
|
2051
|
-
if (ch > '%' && ch < 0x7f) {
|
2052
|
-
*d++ = ch;
|
2053
|
-
break;
|
2054
|
-
}
|
2055
|
-
|
2056
|
-
*d++ = '%'; *d++ = *(s - 2); *d++ = *(s - 1);
|
2057
|
-
break;
|
2058
|
-
}
|
2059
|
-
|
2060
|
-
*d++ = ch;
|
2061
|
-
|
2062
|
-
break;
|
2063
|
-
}
|
2064
|
-
|
2065
|
-
/* the invalid quoted character */
|
2066
|
-
|
2067
|
-
break;
|
2068
|
-
}
|
2069
|
-
}
|
2070
|
-
|
2071
|
-
done:
|
2072
|
-
|
2073
|
-
*dst = d;
|
2074
|
-
*src = s;
|
2075
|
-
}
|
2076
|
-
|
2077
|
-
|
2078
|
-
void
|
2079
|
-
ngx_http_lua_inject_req_api(ngx_log_t *log, lua_State *L)
|
2080
|
-
{
|
2081
|
-
/* ngx.req table */
|
2082
|
-
|
2083
|
-
lua_createtable(L, 0 /* narr */, 23 /* nrec */); /* .req */
|
2084
|
-
|
2085
|
-
ngx_http_lua_inject_req_header_api(L);
|
2086
|
-
ngx_http_lua_inject_req_uri_api(log, L);
|
2087
|
-
ngx_http_lua_inject_req_args_api(L);
|
2088
|
-
ngx_http_lua_inject_req_body_api(L);
|
2089
|
-
ngx_http_lua_inject_req_socket_api(L);
|
2090
|
-
ngx_http_lua_inject_req_method_api(L);
|
2091
|
-
ngx_http_lua_inject_req_time_api(L);
|
2092
|
-
|
2093
|
-
lua_setfield(L, -2, "req");
|
2094
|
-
}
|
2095
|
-
|
2096
|
-
|
2097
|
-
static ngx_int_t
|
2098
|
-
ngx_http_lua_handle_exec(lua_State *L, ngx_http_request_t *r,
|
2099
|
-
ngx_http_lua_ctx_t *ctx)
|
2100
|
-
{
|
2101
|
-
ngx_int_t rc;
|
2102
|
-
|
2103
|
-
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
2104
|
-
"lua thread initiated internal redirect to %V",
|
2105
|
-
&ctx->exec_uri);
|
2106
|
-
|
2107
|
-
ngx_http_lua_cleanup_pending_operation(ctx->cur_co_ctx);
|
2108
|
-
|
2109
|
-
ngx_http_lua_probe_coroutine_done(r, ctx->cur_co_ctx->co, 1);
|
2110
|
-
|
2111
|
-
ctx->cur_co_ctx->co_status = NGX_HTTP_LUA_CO_DEAD;
|
2112
|
-
|
2113
|
-
if (r->filter_finalize) {
|
2114
|
-
ngx_http_set_ctx(r, ctx, ngx_http_lua_module);
|
2115
|
-
}
|
2116
|
-
|
2117
|
-
ngx_http_lua_request_cleanup(ctx, 1 /* forcible */);
|
2118
|
-
|
2119
|
-
if (ctx->exec_uri.data[0] == '@') {
|
2120
|
-
if (ctx->exec_args.len > 0) {
|
2121
|
-
ngx_log_error(NGX_LOG_WARN, r->connection->log, 0,
|
2122
|
-
"query strings %V ignored when exec'ing "
|
2123
|
-
"named location %V",
|
2124
|
-
&ctx->exec_args, &ctx->exec_uri);
|
2125
|
-
}
|
2126
|
-
|
2127
|
-
r->write_event_handler = ngx_http_request_empty_handler;
|
2128
|
-
|
2129
|
-
#if 1
|
2130
|
-
if (r->read_event_handler == ngx_http_lua_rd_check_broken_connection) {
|
2131
|
-
/* resume the read event handler */
|
2132
|
-
|
2133
|
-
r->read_event_handler = ngx_http_block_reading;
|
2134
|
-
}
|
2135
|
-
#endif
|
2136
|
-
|
2137
|
-
#if 1
|
2138
|
-
/* clear the modules contexts */
|
2139
|
-
ngx_memzero(r->ctx, sizeof(void *) * ngx_http_max_module);
|
2140
|
-
#endif
|
2141
|
-
|
2142
|
-
rc = ngx_http_named_location(r, &ctx->exec_uri);
|
2143
|
-
if (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE)
|
2144
|
-
{
|
2145
|
-
return rc;
|
2146
|
-
}
|
2147
|
-
|
2148
|
-
#if 0
|
2149
|
-
if (!ctx->entered_content_phase) {
|
2150
|
-
/* XXX ensure the main request ref count
|
2151
|
-
* is decreased because the current
|
2152
|
-
* request will be quit */
|
2153
|
-
r->main->count--;
|
2154
|
-
dd("XXX decrement main count: c:%d", (int) r->main->count);
|
2155
|
-
}
|
2156
|
-
#endif
|
2157
|
-
|
2158
|
-
return NGX_DONE;
|
2159
|
-
}
|
2160
|
-
|
2161
|
-
dd("internal redirect to %.*s", (int) ctx->exec_uri.len,
|
2162
|
-
ctx->exec_uri.data);
|
2163
|
-
|
2164
|
-
r->write_event_handler = ngx_http_request_empty_handler;
|
2165
|
-
|
2166
|
-
if (r->read_event_handler == ngx_http_lua_rd_check_broken_connection) {
|
2167
|
-
/* resume the read event handler */
|
2168
|
-
|
2169
|
-
r->read_event_handler = ngx_http_block_reading;
|
2170
|
-
}
|
2171
|
-
|
2172
|
-
rc = ngx_http_internal_redirect(r, &ctx->exec_uri, &ctx->exec_args);
|
2173
|
-
|
2174
|
-
dd("internal redirect returned %d when in content phase? "
|
2175
|
-
"%d", (int) rc, ctx->entered_content_phase);
|
2176
|
-
|
2177
|
-
if (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE) {
|
2178
|
-
return rc;
|
2179
|
-
}
|
2180
|
-
|
2181
|
-
#if 0
|
2182
|
-
if (!ctx->entered_content_phase) {
|
2183
|
-
/* XXX ensure the main request ref count
|
2184
|
-
* is decreased because the current
|
2185
|
-
* request will be quit */
|
2186
|
-
dd("XXX decrement main count");
|
2187
|
-
r->main->count--;
|
2188
|
-
}
|
2189
|
-
#endif
|
2190
|
-
|
2191
|
-
return NGX_DONE;
|
2192
|
-
}
|
2193
|
-
|
2194
|
-
|
2195
|
-
static ngx_int_t
|
2196
|
-
ngx_http_lua_handle_exit(lua_State *L, ngx_http_request_t *r,
|
2197
|
-
ngx_http_lua_ctx_t *ctx)
|
2198
|
-
{
|
2199
|
-
ngx_int_t rc;
|
2200
|
-
|
2201
|
-
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
2202
|
-
"lua thread aborting request with status %d",
|
2203
|
-
ctx->exit_code);
|
2204
|
-
|
2205
|
-
#if 1
|
2206
|
-
if (!r->header_sent
|
2207
|
-
&& r->headers_out.status == 0
|
2208
|
-
&& ctx->exit_code >= NGX_HTTP_OK)
|
2209
|
-
{
|
2210
|
-
r->headers_out.status = ctx->exit_code;
|
2211
|
-
}
|
2212
|
-
#endif
|
2213
|
-
|
2214
|
-
ngx_http_lua_cleanup_pending_operation(ctx->cur_co_ctx);
|
2215
|
-
|
2216
|
-
ngx_http_lua_probe_coroutine_done(r, ctx->cur_co_ctx->co, 1);
|
2217
|
-
|
2218
|
-
ctx->cur_co_ctx->co_status = NGX_HTTP_LUA_CO_DEAD;
|
2219
|
-
|
2220
|
-
if (r->filter_finalize) {
|
2221
|
-
ngx_http_set_ctx(r, ctx, ngx_http_lua_module);
|
2222
|
-
}
|
2223
|
-
|
2224
|
-
ngx_http_lua_request_cleanup(ctx, 0);
|
2225
|
-
|
2226
|
-
if (ctx->buffering
|
2227
|
-
&& r->headers_out.status
|
2228
|
-
&& ctx->exit_code != NGX_ERROR
|
2229
|
-
&& ctx->exit_code != NGX_HTTP_REQUEST_TIME_OUT
|
2230
|
-
&& ctx->exit_code != NGX_HTTP_CLIENT_CLOSED_REQUEST
|
2231
|
-
&& ctx->exit_code != NGX_HTTP_CLOSE)
|
2232
|
-
{
|
2233
|
-
rc = ngx_http_lua_send_chain_link(r, ctx, NULL /* indicate last_buf */);
|
2234
|
-
|
2235
|
-
if (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE) {
|
2236
|
-
return rc;
|
2237
|
-
}
|
2238
|
-
|
2239
|
-
if (ctx->exit_code >= NGX_HTTP_OK) {
|
2240
|
-
return NGX_HTTP_OK;
|
2241
|
-
}
|
2242
|
-
|
2243
|
-
return ctx->exit_code;
|
2244
|
-
}
|
2245
|
-
|
2246
|
-
if ((ctx->exit_code == NGX_OK
|
2247
|
-
&& ctx->entered_content_phase)
|
2248
|
-
|| (ctx->exit_code >= NGX_HTTP_OK
|
2249
|
-
&& ctx->exit_code < NGX_HTTP_SPECIAL_RESPONSE
|
2250
|
-
&& ctx->exit_code != NGX_HTTP_NO_CONTENT))
|
2251
|
-
{
|
2252
|
-
rc = ngx_http_lua_send_chain_link(r, ctx, NULL /* indicate last_buf */);
|
2253
|
-
|
2254
|
-
if (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE) {
|
2255
|
-
return rc;
|
2256
|
-
}
|
2257
|
-
}
|
2258
|
-
|
2259
|
-
#if 1
|
2260
|
-
if (r->header_sent
|
2261
|
-
&& ctx->exit_code > NGX_OK
|
2262
|
-
&& ctx->exit_code != NGX_HTTP_REQUEST_TIME_OUT
|
2263
|
-
&& ctx->exit_code != NGX_HTTP_CLIENT_CLOSED_REQUEST
|
2264
|
-
&& ctx->exit_code != NGX_HTTP_CLOSE)
|
2265
|
-
{
|
2266
|
-
if (ctx->entered_content_phase) {
|
2267
|
-
return NGX_OK;
|
2268
|
-
}
|
2269
|
-
|
2270
|
-
return NGX_HTTP_OK;
|
2271
|
-
}
|
2272
|
-
#endif
|
2273
|
-
|
2274
|
-
return ctx->exit_code;
|
2275
|
-
}
|
2276
|
-
|
2277
|
-
|
2278
|
-
void
|
2279
|
-
ngx_http_lua_process_args_option(ngx_http_request_t *r, lua_State *L,
|
2280
|
-
int table, ngx_str_t *args)
|
2281
|
-
{
|
2282
|
-
u_char *key;
|
2283
|
-
size_t key_len;
|
2284
|
-
u_char *value;
|
2285
|
-
size_t value_len;
|
2286
|
-
size_t len = 0;
|
2287
|
-
size_t key_escape = 0;
|
2288
|
-
uintptr_t total_escape = 0;
|
2289
|
-
int n;
|
2290
|
-
int i;
|
2291
|
-
u_char *p;
|
2292
|
-
|
2293
|
-
if (table < 0) {
|
2294
|
-
table = lua_gettop(L) + table + 1;
|
2295
|
-
}
|
2296
|
-
|
2297
|
-
n = 0;
|
2298
|
-
lua_pushnil(L);
|
2299
|
-
while (lua_next(L, table) != 0) {
|
2300
|
-
if (lua_type(L, -2) != LUA_TSTRING) {
|
2301
|
-
luaL_error(L, "attempt to use a non-string key in the "
|
2302
|
-
"\"args\" option table");
|
2303
|
-
return;
|
2304
|
-
}
|
2305
|
-
|
2306
|
-
key = (u_char *) lua_tolstring(L, -2, &key_len);
|
2307
|
-
|
2308
|
-
key_escape = 2 * ngx_http_lua_escape_uri(NULL, key, key_len,
|
2309
|
-
NGX_ESCAPE_URI);
|
2310
|
-
total_escape += key_escape;
|
2311
|
-
|
2312
|
-
switch (lua_type(L, -1)) {
|
2313
|
-
case LUA_TNUMBER:
|
2314
|
-
case LUA_TSTRING:
|
2315
|
-
value = (u_char *) lua_tolstring(L, -1, &value_len);
|
2316
|
-
|
2317
|
-
total_escape += 2 * ngx_http_lua_escape_uri(NULL, value, value_len,
|
2318
|
-
NGX_ESCAPE_URI);
|
2319
|
-
|
2320
|
-
len += key_len + value_len + (sizeof("=") - 1);
|
2321
|
-
n++;
|
2322
|
-
|
2323
|
-
break;
|
2324
|
-
|
2325
|
-
case LUA_TBOOLEAN:
|
2326
|
-
if (lua_toboolean(L, -1)) {
|
2327
|
-
len += key_len;
|
2328
|
-
n++;
|
2329
|
-
}
|
2330
|
-
|
2331
|
-
break;
|
2332
|
-
|
2333
|
-
case LUA_TTABLE:
|
2334
|
-
|
2335
|
-
i = 0;
|
2336
|
-
lua_pushnil(L);
|
2337
|
-
while (lua_next(L, -2) != 0) {
|
2338
|
-
if (lua_isboolean(L, -1)) {
|
2339
|
-
if (lua_toboolean(L, -1)) {
|
2340
|
-
len += key_len;
|
2341
|
-
|
2342
|
-
} else {
|
2343
|
-
lua_pop(L, 1);
|
2344
|
-
continue;
|
2345
|
-
}
|
2346
|
-
|
2347
|
-
} else {
|
2348
|
-
value = (u_char *) lua_tolstring(L, -1, &value_len);
|
2349
|
-
|
2350
|
-
if (value == NULL) {
|
2351
|
-
luaL_error(L, "attempt to use %s as query arg value",
|
2352
|
-
luaL_typename(L, -1));
|
2353
|
-
return;
|
2354
|
-
}
|
2355
|
-
|
2356
|
-
total_escape +=
|
2357
|
-
2 * ngx_http_lua_escape_uri(NULL, value,
|
2358
|
-
value_len,
|
2359
|
-
NGX_ESCAPE_URI);
|
2360
|
-
|
2361
|
-
len += key_len + value_len + (sizeof("=") - 1);
|
2362
|
-
}
|
2363
|
-
|
2364
|
-
if (i++ > 0) {
|
2365
|
-
total_escape += key_escape;
|
2366
|
-
}
|
2367
|
-
|
2368
|
-
n++;
|
2369
|
-
lua_pop(L, 1);
|
2370
|
-
}
|
2371
|
-
|
2372
|
-
break;
|
2373
|
-
|
2374
|
-
default:
|
2375
|
-
luaL_error(L, "attempt to use %s as query arg value",
|
2376
|
-
luaL_typename(L, -1));
|
2377
|
-
return;
|
2378
|
-
}
|
2379
|
-
|
2380
|
-
lua_pop(L, 1);
|
2381
|
-
}
|
2382
|
-
|
2383
|
-
len += (size_t) total_escape;
|
2384
|
-
|
2385
|
-
if (n > 1) {
|
2386
|
-
len += (n - 1) * (sizeof("&") - 1);
|
2387
|
-
}
|
2388
|
-
|
2389
|
-
dd("len 1: %d", (int) len);
|
2390
|
-
|
2391
|
-
if (r) {
|
2392
|
-
p = ngx_palloc(r->pool, len);
|
2393
|
-
if (p == NULL) {
|
2394
|
-
luaL_error(L, "no memory");
|
2395
|
-
return;
|
2396
|
-
}
|
2397
|
-
|
2398
|
-
} else {
|
2399
|
-
p = lua_newuserdata(L, len);
|
2400
|
-
}
|
2401
|
-
|
2402
|
-
args->data = p;
|
2403
|
-
args->len = len;
|
2404
|
-
|
2405
|
-
i = 0;
|
2406
|
-
lua_pushnil(L);
|
2407
|
-
while (lua_next(L, table) != 0) {
|
2408
|
-
key = (u_char *) lua_tolstring(L, -2, &key_len);
|
2409
|
-
|
2410
|
-
switch (lua_type(L, -1)) {
|
2411
|
-
case LUA_TNUMBER:
|
2412
|
-
case LUA_TSTRING:
|
2413
|
-
|
2414
|
-
if (total_escape) {
|
2415
|
-
p = (u_char *) ngx_http_lua_escape_uri(p, key, key_len,
|
2416
|
-
NGX_ESCAPE_URI);
|
2417
|
-
|
2418
|
-
} else {
|
2419
|
-
dd("shortcut: no escape required");
|
2420
|
-
|
2421
|
-
p = ngx_copy(p, key, key_len);
|
2422
|
-
}
|
2423
|
-
|
2424
|
-
*p++ = '=';
|
2425
|
-
|
2426
|
-
value = (u_char *) lua_tolstring(L, -1, &value_len);
|
2427
|
-
|
2428
|
-
if (total_escape) {
|
2429
|
-
p = (u_char *) ngx_http_lua_escape_uri(p, value, value_len,
|
2430
|
-
NGX_ESCAPE_URI);
|
2431
|
-
|
2432
|
-
} else {
|
2433
|
-
p = ngx_copy(p, value, value_len);
|
2434
|
-
}
|
2435
|
-
|
2436
|
-
if (i != n - 1) {
|
2437
|
-
/* not the last pair */
|
2438
|
-
*p++ = '&';
|
2439
|
-
}
|
2440
|
-
|
2441
|
-
i++;
|
2442
|
-
|
2443
|
-
break;
|
2444
|
-
|
2445
|
-
case LUA_TBOOLEAN:
|
2446
|
-
if (lua_toboolean(L, -1)) {
|
2447
|
-
if (total_escape) {
|
2448
|
-
p = (u_char *) ngx_http_lua_escape_uri(p, key, key_len,
|
2449
|
-
NGX_ESCAPE_URI);
|
2450
|
-
|
2451
|
-
} else {
|
2452
|
-
dd("shortcut: no escape required");
|
2453
|
-
|
2454
|
-
p = ngx_copy(p, key, key_len);
|
2455
|
-
}
|
2456
|
-
|
2457
|
-
if (i != n - 1) {
|
2458
|
-
/* not the last pair */
|
2459
|
-
*p++ = '&';
|
2460
|
-
}
|
2461
|
-
|
2462
|
-
i++;
|
2463
|
-
}
|
2464
|
-
|
2465
|
-
break;
|
2466
|
-
|
2467
|
-
case LUA_TTABLE:
|
2468
|
-
|
2469
|
-
lua_pushnil(L);
|
2470
|
-
while (lua_next(L, -2) != 0) {
|
2471
|
-
|
2472
|
-
if (lua_isboolean(L, -1)) {
|
2473
|
-
if (lua_toboolean(L, -1)) {
|
2474
|
-
if (total_escape) {
|
2475
|
-
p = (u_char *) ngx_http_lua_escape_uri(p, key,
|
2476
|
-
key_len,
|
2477
|
-
NGX_ESCAPE_URI);
|
2478
|
-
|
2479
|
-
} else {
|
2480
|
-
dd("shortcut: no escape required");
|
2481
|
-
|
2482
|
-
p = ngx_copy(p, key, key_len);
|
2483
|
-
}
|
2484
|
-
|
2485
|
-
} else {
|
2486
|
-
lua_pop(L, 1);
|
2487
|
-
continue;
|
2488
|
-
}
|
2489
|
-
|
2490
|
-
} else {
|
2491
|
-
|
2492
|
-
if (total_escape) {
|
2493
|
-
p = (u_char *)
|
2494
|
-
ngx_http_lua_escape_uri(p, key,
|
2495
|
-
key_len,
|
2496
|
-
NGX_ESCAPE_URI);
|
2497
|
-
|
2498
|
-
} else {
|
2499
|
-
dd("shortcut: no escape required");
|
2500
|
-
|
2501
|
-
p = ngx_copy(p, key, key_len);
|
2502
|
-
}
|
2503
|
-
|
2504
|
-
*p++ = '=';
|
2505
|
-
|
2506
|
-
value = (u_char *) lua_tolstring(L, -1, &value_len);
|
2507
|
-
|
2508
|
-
if (total_escape) {
|
2509
|
-
p = (u_char *)
|
2510
|
-
ngx_http_lua_escape_uri(p, value,
|
2511
|
-
value_len,
|
2512
|
-
NGX_ESCAPE_URI);
|
2513
|
-
|
2514
|
-
} else {
|
2515
|
-
p = ngx_copy(p, value, value_len);
|
2516
|
-
}
|
2517
|
-
}
|
2518
|
-
|
2519
|
-
if (i != n - 1) {
|
2520
|
-
/* not the last pair */
|
2521
|
-
*p++ = '&';
|
2522
|
-
}
|
2523
|
-
|
2524
|
-
i++;
|
2525
|
-
lua_pop(L, 1);
|
2526
|
-
}
|
2527
|
-
|
2528
|
-
break;
|
2529
|
-
|
2530
|
-
default:
|
2531
|
-
luaL_error(L, "should not reach here");
|
2532
|
-
return;
|
2533
|
-
}
|
2534
|
-
|
2535
|
-
lua_pop(L, 1);
|
2536
|
-
}
|
2537
|
-
|
2538
|
-
if (p - args->data != (ssize_t) len) {
|
2539
|
-
luaL_error(L, "buffer error: %d != %d",
|
2540
|
-
(int) (p - args->data), (int) len);
|
2541
|
-
return;
|
2542
|
-
}
|
2543
|
-
}
|
2544
|
-
|
2545
|
-
|
2546
|
-
static ngx_int_t
|
2547
|
-
ngx_http_lua_handle_rewrite_jump(lua_State *L, ngx_http_request_t *r,
|
2548
|
-
ngx_http_lua_ctx_t *ctx)
|
2549
|
-
{
|
2550
|
-
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
2551
|
-
"lua thread aborting request with URI rewrite jump: "
|
2552
|
-
"\"%V?%V\"", &r->uri, &r->args);
|
2553
|
-
|
2554
|
-
ngx_http_lua_cleanup_pending_operation(ctx->cur_co_ctx);
|
2555
|
-
|
2556
|
-
ngx_http_lua_probe_coroutine_done(r, ctx->cur_co_ctx->co, 1);
|
2557
|
-
|
2558
|
-
ctx->cur_co_ctx->co_status = NGX_HTTP_LUA_CO_DEAD;
|
2559
|
-
|
2560
|
-
if (r->filter_finalize) {
|
2561
|
-
ngx_http_set_ctx(r, ctx, ngx_http_lua_module);
|
2562
|
-
}
|
2563
|
-
|
2564
|
-
ngx_http_lua_request_cleanup(ctx, 1 /* forcible */);
|
2565
|
-
ngx_http_lua_init_ctx(r, ctx);
|
2566
|
-
|
2567
|
-
return NGX_OK;
|
2568
|
-
}
|
2569
|
-
|
2570
|
-
|
2571
|
-
/* XXX ngx_open_and_stat_file is static in the core. sigh. */
|
2572
|
-
ngx_int_t
|
2573
|
-
ngx_http_lua_open_and_stat_file(u_char *name, ngx_open_file_info_t *of,
|
2574
|
-
ngx_log_t *log)
|
2575
|
-
{
|
2576
|
-
ngx_fd_t fd;
|
2577
|
-
ngx_file_info_t fi;
|
2578
|
-
|
2579
|
-
if (of->fd != NGX_INVALID_FILE) {
|
2580
|
-
|
2581
|
-
if (ngx_file_info(name, &fi) == NGX_FILE_ERROR) {
|
2582
|
-
of->failed = ngx_file_info_n;
|
2583
|
-
goto failed;
|
2584
|
-
}
|
2585
|
-
|
2586
|
-
if (of->uniq == ngx_file_uniq(&fi)) {
|
2587
|
-
goto done;
|
2588
|
-
}
|
2589
|
-
|
2590
|
-
} else if (of->test_dir) {
|
2591
|
-
|
2592
|
-
if (ngx_file_info(name, &fi) == NGX_FILE_ERROR) {
|
2593
|
-
of->failed = ngx_file_info_n;
|
2594
|
-
goto failed;
|
2595
|
-
}
|
2596
|
-
|
2597
|
-
if (ngx_is_dir(&fi)) {
|
2598
|
-
goto done;
|
2599
|
-
}
|
2600
|
-
}
|
2601
|
-
|
2602
|
-
if (!of->log) {
|
2603
|
-
|
2604
|
-
/*
|
2605
|
-
* Use non-blocking open() not to hang on FIFO files, etc.
|
2606
|
-
* This flag has no effect on a regular files.
|
2607
|
-
*/
|
2608
|
-
|
2609
|
-
fd = ngx_open_file(name, NGX_FILE_RDONLY|NGX_FILE_NONBLOCK,
|
2610
|
-
NGX_FILE_OPEN, 0);
|
2611
|
-
|
2612
|
-
} else {
|
2613
|
-
fd = ngx_open_file(name, NGX_FILE_APPEND, NGX_FILE_CREATE_OR_OPEN,
|
2614
|
-
NGX_FILE_DEFAULT_ACCESS);
|
2615
|
-
}
|
2616
|
-
|
2617
|
-
if (fd == NGX_INVALID_FILE) {
|
2618
|
-
of->failed = ngx_open_file_n;
|
2619
|
-
goto failed;
|
2620
|
-
}
|
2621
|
-
|
2622
|
-
if (ngx_fd_info(fd, &fi) == NGX_FILE_ERROR) {
|
2623
|
-
ngx_log_error(NGX_LOG_CRIT, log, ngx_errno,
|
2624
|
-
ngx_fd_info_n " \"%s\" failed", name);
|
2625
|
-
|
2626
|
-
if (ngx_close_file(fd) == NGX_FILE_ERROR) {
|
2627
|
-
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
|
2628
|
-
ngx_close_file_n " \"%s\" failed", name);
|
2629
|
-
}
|
2630
|
-
|
2631
|
-
of->fd = NGX_INVALID_FILE;
|
2632
|
-
|
2633
|
-
return NGX_ERROR;
|
2634
|
-
}
|
2635
|
-
|
2636
|
-
if (ngx_is_dir(&fi)) {
|
2637
|
-
if (ngx_close_file(fd) == NGX_FILE_ERROR) {
|
2638
|
-
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
|
2639
|
-
ngx_close_file_n " \"%s\" failed", name);
|
2640
|
-
}
|
2641
|
-
|
2642
|
-
of->fd = NGX_INVALID_FILE;
|
2643
|
-
|
2644
|
-
} else {
|
2645
|
-
of->fd = fd;
|
2646
|
-
|
2647
|
-
if (of->directio <= ngx_file_size(&fi)) {
|
2648
|
-
if (ngx_directio_on(fd) == NGX_FILE_ERROR) {
|
2649
|
-
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
|
2650
|
-
ngx_directio_on_n " \"%s\" failed", name);
|
2651
|
-
|
2652
|
-
} else {
|
2653
|
-
of->is_directio = 1;
|
2654
|
-
}
|
2655
|
-
}
|
2656
|
-
}
|
2657
|
-
|
2658
|
-
done:
|
2659
|
-
|
2660
|
-
of->uniq = ngx_file_uniq(&fi);
|
2661
|
-
of->mtime = ngx_file_mtime(&fi);
|
2662
|
-
of->size = ngx_file_size(&fi);
|
2663
|
-
#if defined(nginx_version) && nginx_version >= 1000001
|
2664
|
-
of->fs_size = ngx_file_fs_size(&fi);
|
2665
|
-
#endif
|
2666
|
-
of->is_dir = ngx_is_dir(&fi);
|
2667
|
-
of->is_file = ngx_is_file(&fi);
|
2668
|
-
of->is_link = ngx_is_link(&fi);
|
2669
|
-
of->is_exec = ngx_is_exec(&fi);
|
2670
|
-
|
2671
|
-
return NGX_OK;
|
2672
|
-
|
2673
|
-
failed:
|
2674
|
-
|
2675
|
-
of->fd = NGX_INVALID_FILE;
|
2676
|
-
of->err = ngx_errno;
|
2677
|
-
|
2678
|
-
return NGX_ERROR;
|
2679
|
-
}
|
2680
|
-
|
2681
|
-
|
2682
|
-
ngx_chain_t *
|
2683
|
-
ngx_http_lua_chain_get_free_buf(ngx_log_t *log, ngx_pool_t *p,
|
2684
|
-
ngx_chain_t **free, size_t len)
|
2685
|
-
{
|
2686
|
-
ngx_buf_t *b;
|
2687
|
-
ngx_chain_t *cl;
|
2688
|
-
u_char *start, *end;
|
2689
|
-
|
2690
|
-
const ngx_buf_tag_t tag = (ngx_buf_tag_t) &ngx_http_lua_module;
|
2691
|
-
|
2692
|
-
if (*free) {
|
2693
|
-
cl = *free;
|
2694
|
-
*free = cl->next;
|
2695
|
-
cl->next = NULL;
|
2696
|
-
|
2697
|
-
b = cl->buf;
|
2698
|
-
start = b->start;
|
2699
|
-
end = b->end;
|
2700
|
-
if (start && (size_t) (end - start) >= len) {
|
2701
|
-
ngx_log_debug4(NGX_LOG_DEBUG_HTTP, log, 0,
|
2702
|
-
"lua reuse free buf memory %O >= %uz, cl:%p, p:%p",
|
2703
|
-
(off_t) (end - start), len, cl, start);
|
2704
|
-
|
2705
|
-
ngx_memzero(b, sizeof(ngx_buf_t));
|
2706
|
-
|
2707
|
-
b->start = start;
|
2708
|
-
b->pos = start;
|
2709
|
-
b->last = start;
|
2710
|
-
b->end = end;
|
2711
|
-
b->tag = tag;
|
2712
|
-
|
2713
|
-
if (len) {
|
2714
|
-
b->temporary = 1;
|
2715
|
-
}
|
2716
|
-
|
2717
|
-
return cl;
|
2718
|
-
}
|
2719
|
-
|
2720
|
-
ngx_log_debug4(NGX_LOG_DEBUG_HTTP, log, 0,
|
2721
|
-
"lua reuse free buf chain, but reallocate memory "
|
2722
|
-
"because %uz >= %O, cl:%p, p:%p", len,
|
2723
|
-
(off_t) (b->end - b->start), cl, b->start);
|
2724
|
-
|
2725
|
-
if (ngx_buf_in_memory(b) && b->start) {
|
2726
|
-
ngx_pfree(p, b->start);
|
2727
|
-
}
|
2728
|
-
|
2729
|
-
ngx_memzero(b, sizeof(ngx_buf_t));
|
2730
|
-
|
2731
|
-
if (len == 0) {
|
2732
|
-
return cl;
|
2733
|
-
}
|
2734
|
-
|
2735
|
-
b->start = ngx_palloc(p, len);
|
2736
|
-
if (b->start == NULL) {
|
2737
|
-
return NULL;
|
2738
|
-
}
|
2739
|
-
|
2740
|
-
b->end = b->start + len;
|
2741
|
-
|
2742
|
-
dd("buf start: %p", cl->buf->start);
|
2743
|
-
|
2744
|
-
b->pos = b->start;
|
2745
|
-
b->last = b->start;
|
2746
|
-
b->tag = tag;
|
2747
|
-
b->temporary = 1;
|
2748
|
-
|
2749
|
-
return cl;
|
2750
|
-
}
|
2751
|
-
|
2752
|
-
cl = ngx_alloc_chain_link(p);
|
2753
|
-
if (cl == NULL) {
|
2754
|
-
return NULL;
|
2755
|
-
}
|
2756
|
-
|
2757
|
-
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, log, 0,
|
2758
|
-
"lua allocate new chainlink and new buf of size %uz, cl:%p",
|
2759
|
-
len, cl);
|
2760
|
-
|
2761
|
-
cl->buf = len ? ngx_create_temp_buf(p, len) : ngx_calloc_buf(p);
|
2762
|
-
if (cl->buf == NULL) {
|
2763
|
-
return NULL;
|
2764
|
-
}
|
2765
|
-
|
2766
|
-
dd("buf start: %p", cl->buf->start);
|
2767
|
-
|
2768
|
-
cl->buf->tag = tag;
|
2769
|
-
cl->next = NULL;
|
2770
|
-
|
2771
|
-
return cl;
|
2772
|
-
}
|
2773
|
-
|
2774
|
-
|
2775
|
-
static int
|
2776
|
-
ngx_http_lua_thread_traceback(lua_State *L, lua_State *co,
|
2777
|
-
ngx_http_lua_co_ctx_t *coctx)
|
2778
|
-
{
|
2779
|
-
int base;
|
2780
|
-
int level, coid;
|
2781
|
-
lua_Debug ar;
|
2782
|
-
|
2783
|
-
base = lua_gettop(L);
|
2784
|
-
lua_checkstack(L, 3);
|
2785
|
-
lua_pushliteral(L, "stack traceback:");
|
2786
|
-
coid = 0;
|
2787
|
-
|
2788
|
-
while (co) {
|
2789
|
-
|
2790
|
-
if (coid >= NGX_HTTP_LUA_BT_MAX_COROS) {
|
2791
|
-
break;
|
2792
|
-
}
|
2793
|
-
|
2794
|
-
lua_checkstack(L, 2);
|
2795
|
-
lua_pushfstring(L, "\ncoroutine %d:", coid++);
|
2796
|
-
|
2797
|
-
level = 0;
|
2798
|
-
|
2799
|
-
while (lua_getstack(co, level++, &ar)) {
|
2800
|
-
|
2801
|
-
lua_checkstack(L, 5);
|
2802
|
-
|
2803
|
-
if (level > NGX_HTTP_LUA_BT_DEPTH) {
|
2804
|
-
lua_pushliteral(L, "\n\t...");
|
2805
|
-
break;
|
2806
|
-
}
|
2807
|
-
|
2808
|
-
lua_pushliteral(L, "\n\t");
|
2809
|
-
lua_getinfo(co, "Snl", &ar);
|
2810
|
-
lua_pushfstring(L, "%s:", ar.short_src);
|
2811
|
-
|
2812
|
-
if (ar.currentline > 0) {
|
2813
|
-
lua_pushfstring(L, "%d:", ar.currentline);
|
2814
|
-
}
|
2815
|
-
|
2816
|
-
if (*ar.namewhat != '\0') { /* is there a name? */
|
2817
|
-
lua_pushfstring(L, " in function " LUA_QS, ar.name);
|
2818
|
-
|
2819
|
-
} else {
|
2820
|
-
if (*ar.what == 'm') { /* main? */
|
2821
|
-
lua_pushliteral(L, " in main chunk");
|
2822
|
-
|
2823
|
-
} else if (*ar.what == 'C' || *ar.what == 't') {
|
2824
|
-
lua_pushliteral(L, " ?"); /* C function or tail call */
|
2825
|
-
|
2826
|
-
} else {
|
2827
|
-
lua_pushfstring(L, " in function <%s:%d>",
|
2828
|
-
ar.short_src, ar.linedefined);
|
2829
|
-
}
|
2830
|
-
}
|
2831
|
-
}
|
2832
|
-
|
2833
|
-
if (lua_gettop(L) - base >= 15) {
|
2834
|
-
lua_concat(L, lua_gettop(L) - base);
|
2835
|
-
}
|
2836
|
-
|
2837
|
-
/* check if the coroutine has a parent coroutine*/
|
2838
|
-
coctx = coctx->parent_co_ctx;
|
2839
|
-
if (!coctx || coctx->co_status == NGX_HTTP_LUA_CO_DEAD) {
|
2840
|
-
break;
|
2841
|
-
}
|
2842
|
-
|
2843
|
-
co = coctx->co;
|
2844
|
-
}
|
2845
|
-
|
2846
|
-
lua_concat(L, lua_gettop(L) - base);
|
2847
|
-
return 1;
|
2848
|
-
}
|
2849
|
-
|
2850
|
-
|
2851
|
-
int
|
2852
|
-
ngx_http_lua_traceback(lua_State *L)
|
2853
|
-
{
|
2854
|
-
if (!lua_isstring(L, 1)) { /* 'message' not a string? */
|
2855
|
-
return 1; /* keep it intact */
|
2856
|
-
}
|
2857
|
-
|
2858
|
-
lua_getglobal(L, "debug");
|
2859
|
-
if (!lua_istable(L, -1)) {
|
2860
|
-
lua_pop(L, 1);
|
2861
|
-
return 1;
|
2862
|
-
}
|
2863
|
-
|
2864
|
-
lua_getfield(L, -1, "traceback");
|
2865
|
-
if (!lua_isfunction(L, -1)) {
|
2866
|
-
lua_pop(L, 2);
|
2867
|
-
return 1;
|
2868
|
-
}
|
2869
|
-
|
2870
|
-
lua_pushvalue(L, 1); /* pass error message */
|
2871
|
-
lua_pushinteger(L, 2); /* skip this function and traceback */
|
2872
|
-
lua_call(L, 2, 1); /* call debug.traceback */
|
2873
|
-
return 1;
|
2874
|
-
}
|
2875
|
-
|
2876
|
-
|
2877
|
-
static void
|
2878
|
-
ngx_http_lua_inject_arg_api(lua_State *L)
|
2879
|
-
{
|
2880
|
-
lua_pushliteral(L, "arg");
|
2881
|
-
lua_newtable(L); /* .arg table aka {} */
|
2882
|
-
|
2883
|
-
lua_createtable(L, 0 /* narr */, 2 /* nrec */); /* the metatable */
|
2884
|
-
|
2885
|
-
lua_pushcfunction(L, ngx_http_lua_param_get);
|
2886
|
-
lua_setfield(L, -2, "__index");
|
2887
|
-
|
2888
|
-
lua_pushcfunction(L, ngx_http_lua_param_set);
|
2889
|
-
lua_setfield(L, -2, "__newindex");
|
2890
|
-
|
2891
|
-
lua_setmetatable(L, -2); /* tie the metatable to param table */
|
2892
|
-
|
2893
|
-
dd("top: %d, type -1: %s", lua_gettop(L), luaL_typename(L, -1));
|
2894
|
-
|
2895
|
-
lua_rawset(L, -3); /* set ngx.arg table */
|
2896
|
-
}
|
2897
|
-
|
2898
|
-
|
2899
|
-
static int
|
2900
|
-
ngx_http_lua_param_get(lua_State *L)
|
2901
|
-
{
|
2902
|
-
ngx_http_lua_ctx_t *ctx;
|
2903
|
-
ngx_http_request_t *r;
|
2904
|
-
|
2905
|
-
r = ngx_http_lua_get_req(L);
|
2906
|
-
if (r == NULL) {
|
2907
|
-
return 0;
|
2908
|
-
}
|
2909
|
-
|
2910
|
-
ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module);
|
2911
|
-
if (ctx == NULL) {
|
2912
|
-
return luaL_error(L, "ctx not found");
|
2913
|
-
}
|
2914
|
-
|
2915
|
-
ngx_http_lua_check_context(L, ctx, NGX_HTTP_LUA_CONTEXT_SET
|
2916
|
-
| NGX_HTTP_LUA_CONTEXT_BODY_FILTER);
|
2917
|
-
|
2918
|
-
if (ctx->context & (NGX_HTTP_LUA_CONTEXT_SET)) {
|
2919
|
-
return ngx_http_lua_setby_param_get(L);
|
2920
|
-
}
|
2921
|
-
|
2922
|
-
/* ctx->context & (NGX_HTTP_LUA_CONTEXT_BODY_FILTER) */
|
2923
|
-
|
2924
|
-
return ngx_http_lua_body_filter_param_get(L);
|
2925
|
-
}
|
2926
|
-
|
2927
|
-
|
2928
|
-
static int
|
2929
|
-
ngx_http_lua_param_set(lua_State *L)
|
2930
|
-
{
|
2931
|
-
ngx_http_lua_ctx_t *ctx;
|
2932
|
-
ngx_http_request_t *r;
|
2933
|
-
|
2934
|
-
r = ngx_http_lua_get_req(L);
|
2935
|
-
if (r == NULL) {
|
2936
|
-
return 0;
|
2937
|
-
}
|
2938
|
-
|
2939
|
-
ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module);
|
2940
|
-
if (ctx == NULL) {
|
2941
|
-
return luaL_error(L, "ctx not found");
|
2942
|
-
}
|
2943
|
-
|
2944
|
-
ngx_http_lua_check_context(L, ctx, NGX_HTTP_LUA_CONTEXT_BODY_FILTER);
|
2945
|
-
|
2946
|
-
return ngx_http_lua_body_filter_param_set(L, r, ctx);
|
2947
|
-
}
|
2948
|
-
|
2949
|
-
|
2950
|
-
ngx_http_lua_co_ctx_t *
|
2951
|
-
ngx_http_lua_get_co_ctx(lua_State *L, ngx_http_lua_ctx_t *ctx)
|
2952
|
-
{
|
2953
|
-
ngx_uint_t i;
|
2954
|
-
ngx_list_part_t *part;
|
2955
|
-
ngx_http_lua_co_ctx_t *coctx;
|
2956
|
-
|
2957
|
-
if (L == ctx->entry_co_ctx.co) {
|
2958
|
-
return &ctx->entry_co_ctx;
|
2959
|
-
}
|
2960
|
-
|
2961
|
-
if (ctx->user_co_ctx == NULL) {
|
2962
|
-
return NULL;
|
2963
|
-
}
|
2964
|
-
|
2965
|
-
part = &ctx->user_co_ctx->part;
|
2966
|
-
coctx = part->elts;
|
2967
|
-
|
2968
|
-
/* FIXME: we should use rbtree here to prevent O(n) lookup overhead */
|
2969
|
-
|
2970
|
-
for (i = 0; /* void */; i++) {
|
2971
|
-
|
2972
|
-
if (i >= part->nelts) {
|
2973
|
-
if (part->next == NULL) {
|
2974
|
-
break;
|
2975
|
-
}
|
2976
|
-
|
2977
|
-
part = part->next;
|
2978
|
-
coctx = part->elts;
|
2979
|
-
i = 0;
|
2980
|
-
}
|
2981
|
-
|
2982
|
-
if (coctx[i].co == L) {
|
2983
|
-
return &coctx[i];
|
2984
|
-
}
|
2985
|
-
}
|
2986
|
-
|
2987
|
-
return NULL;
|
2988
|
-
}
|
2989
|
-
|
2990
|
-
|
2991
|
-
ngx_http_lua_co_ctx_t *
|
2992
|
-
ngx_http_lua_create_co_ctx(ngx_http_request_t *r, ngx_http_lua_ctx_t *ctx)
|
2993
|
-
{
|
2994
|
-
ngx_http_lua_co_ctx_t *coctx;
|
2995
|
-
|
2996
|
-
if (ctx->user_co_ctx == NULL) {
|
2997
|
-
ctx->user_co_ctx = ngx_list_create(r->pool, 4,
|
2998
|
-
sizeof(ngx_http_lua_co_ctx_t));
|
2999
|
-
if (ctx->user_co_ctx == NULL) {
|
3000
|
-
return NULL;
|
3001
|
-
}
|
3002
|
-
}
|
3003
|
-
|
3004
|
-
coctx = ngx_list_push(ctx->user_co_ctx);
|
3005
|
-
if (coctx == NULL) {
|
3006
|
-
return NULL;
|
3007
|
-
}
|
3008
|
-
|
3009
|
-
ngx_memzero(coctx, sizeof(ngx_http_lua_co_ctx_t));
|
3010
|
-
|
3011
|
-
coctx->co_ref = LUA_NOREF;
|
3012
|
-
|
3013
|
-
return coctx;
|
3014
|
-
}
|
3015
|
-
|
3016
|
-
|
3017
|
-
/* this is for callers other than the content handler */
|
3018
|
-
ngx_int_t
|
3019
|
-
ngx_http_lua_run_posted_threads(ngx_connection_t *c, lua_State *L,
|
3020
|
-
ngx_http_request_t *r, ngx_http_lua_ctx_t *ctx)
|
3021
|
-
{
|
3022
|
-
ngx_int_t rc;
|
3023
|
-
ngx_http_lua_posted_thread_t *pt;
|
3024
|
-
|
3025
|
-
for ( ;; ) {
|
3026
|
-
if (c->destroyed) {
|
3027
|
-
return NGX_DONE;
|
3028
|
-
}
|
3029
|
-
|
3030
|
-
pt = ctx->posted_threads;
|
3031
|
-
if (pt == NULL) {
|
3032
|
-
return NGX_DONE;
|
3033
|
-
}
|
3034
|
-
|
3035
|
-
ctx->posted_threads = pt->next;
|
3036
|
-
|
3037
|
-
ngx_http_lua_probe_run_posted_thread(r, pt->co_ctx->co,
|
3038
|
-
(int) pt->co_ctx->co_status);
|
3039
|
-
|
3040
|
-
if (pt->co_ctx->co_status != NGX_HTTP_LUA_CO_RUNNING) {
|
3041
|
-
continue;
|
3042
|
-
}
|
3043
|
-
|
3044
|
-
ctx->cur_co_ctx = pt->co_ctx;
|
3045
|
-
|
3046
|
-
rc = ngx_http_lua_run_thread(L, r, ctx, 0);
|
3047
|
-
|
3048
|
-
if (rc == NGX_AGAIN) {
|
3049
|
-
continue;
|
3050
|
-
}
|
3051
|
-
|
3052
|
-
if (rc == NGX_DONE) {
|
3053
|
-
ngx_http_lua_finalize_request(r, NGX_DONE);
|
3054
|
-
continue;
|
3055
|
-
}
|
3056
|
-
|
3057
|
-
/* rc == NGX_ERROR || rc >= NGX_OK */
|
3058
|
-
|
3059
|
-
if (ctx->entered_content_phase) {
|
3060
|
-
ngx_http_lua_finalize_request(r, rc);
|
3061
|
-
}
|
3062
|
-
|
3063
|
-
return rc;
|
3064
|
-
}
|
3065
|
-
|
3066
|
-
/* impossible to reach here */
|
3067
|
-
}
|
3068
|
-
|
3069
|
-
|
3070
|
-
ngx_int_t
|
3071
|
-
ngx_http_lua_post_thread(ngx_http_request_t *r, ngx_http_lua_ctx_t *ctx,
|
3072
|
-
ngx_http_lua_co_ctx_t *coctx)
|
3073
|
-
{
|
3074
|
-
ngx_http_lua_posted_thread_t **p;
|
3075
|
-
ngx_http_lua_posted_thread_t *pt;
|
3076
|
-
|
3077
|
-
pt = ngx_palloc(r->pool, sizeof(ngx_http_lua_posted_thread_t));
|
3078
|
-
if (pt == NULL) {
|
3079
|
-
return NGX_ERROR;
|
3080
|
-
}
|
3081
|
-
|
3082
|
-
pt->co_ctx = coctx;
|
3083
|
-
pt->next = NULL;
|
3084
|
-
|
3085
|
-
for (p = &ctx->posted_threads; *p; p = &(*p)->next) { /* void */ }
|
3086
|
-
|
3087
|
-
*p = pt;
|
3088
|
-
|
3089
|
-
return NGX_OK;
|
3090
|
-
}
|
3091
|
-
|
3092
|
-
|
3093
|
-
static void
|
3094
|
-
ngx_http_lua_finalize_threads(ngx_http_request_t *r,
|
3095
|
-
ngx_http_lua_ctx_t *ctx, lua_State *L)
|
3096
|
-
{
|
3097
|
-
#ifdef NGX_LUA_USE_ASSERT
|
3098
|
-
int top;
|
3099
|
-
#endif
|
3100
|
-
int inited = 0, ref;
|
3101
|
-
ngx_uint_t i;
|
3102
|
-
ngx_list_part_t *part;
|
3103
|
-
ngx_http_lua_co_ctx_t *cc, *coctx;
|
3104
|
-
|
3105
|
-
#ifdef NGX_LUA_USE_ASSERT
|
3106
|
-
top = lua_gettop(L);
|
3107
|
-
#endif
|
3108
|
-
|
3109
|
-
#if 1
|
3110
|
-
coctx = ctx->on_abort_co_ctx;
|
3111
|
-
if (coctx && coctx->co_ref != LUA_NOREF) {
|
3112
|
-
if (coctx->co_status != NGX_HTTP_LUA_CO_SUSPENDED) {
|
3113
|
-
/* the on_abort thread contributes to the coctx->uthreads
|
3114
|
-
* counter only when it actually starts running */
|
3115
|
-
ngx_http_lua_cleanup_pending_operation(coctx);
|
3116
|
-
ctx->uthreads--;
|
3117
|
-
}
|
3118
|
-
|
3119
|
-
ngx_http_lua_probe_thread_delete(r, coctx->co, ctx);
|
3120
|
-
|
3121
|
-
lua_pushlightuserdata(L, &ngx_http_lua_coroutines_key);
|
3122
|
-
lua_rawget(L, LUA_REGISTRYINDEX);
|
3123
|
-
inited = 1;
|
3124
|
-
|
3125
|
-
luaL_unref(L, -1, coctx->co_ref);
|
3126
|
-
coctx->co_ref = LUA_NOREF;
|
3127
|
-
|
3128
|
-
coctx->co_status = NGX_HTTP_LUA_CO_DEAD;
|
3129
|
-
ctx->on_abort_co_ctx = NULL;
|
3130
|
-
}
|
3131
|
-
#endif
|
3132
|
-
|
3133
|
-
if (ctx->user_co_ctx) {
|
3134
|
-
part = &ctx->user_co_ctx->part;
|
3135
|
-
cc = part->elts;
|
3136
|
-
|
3137
|
-
for (i = 0; /* void */; i++) {
|
3138
|
-
|
3139
|
-
if (i >= part->nelts) {
|
3140
|
-
if (part->next == NULL) {
|
3141
|
-
break;
|
3142
|
-
}
|
3143
|
-
|
3144
|
-
part = part->next;
|
3145
|
-
cc = part->elts;
|
3146
|
-
i = 0;
|
3147
|
-
}
|
3148
|
-
|
3149
|
-
coctx = &cc[i];
|
3150
|
-
|
3151
|
-
ref = coctx->co_ref;
|
3152
|
-
|
3153
|
-
if (ref != LUA_NOREF) {
|
3154
|
-
ngx_http_lua_cleanup_pending_operation(coctx);
|
3155
|
-
|
3156
|
-
ngx_http_lua_probe_thread_delete(r, coctx->co, ctx);
|
3157
|
-
|
3158
|
-
if (!inited) {
|
3159
|
-
lua_pushlightuserdata(L, &ngx_http_lua_coroutines_key);
|
3160
|
-
lua_rawget(L, LUA_REGISTRYINDEX);
|
3161
|
-
inited = 1;
|
3162
|
-
}
|
3163
|
-
|
3164
|
-
ngx_http_lua_assert(lua_gettop(L) - top == 1);
|
3165
|
-
|
3166
|
-
luaL_unref(L, -1, ref);
|
3167
|
-
coctx->co_ref = LUA_NOREF;
|
3168
|
-
|
3169
|
-
coctx->co_status = NGX_HTTP_LUA_CO_DEAD;
|
3170
|
-
ctx->uthreads--;
|
3171
|
-
}
|
3172
|
-
}
|
3173
|
-
|
3174
|
-
ctx->user_co_ctx = NULL;
|
3175
|
-
}
|
3176
|
-
|
3177
|
-
ngx_http_lua_assert(ctx->uthreads == 0);
|
3178
|
-
|
3179
|
-
coctx = &ctx->entry_co_ctx;
|
3180
|
-
|
3181
|
-
ref = coctx->co_ref;
|
3182
|
-
if (ref != LUA_NOREF) {
|
3183
|
-
ngx_http_lua_cleanup_pending_operation(coctx);
|
3184
|
-
|
3185
|
-
ngx_http_lua_probe_thread_delete(r, coctx->co, ctx);
|
3186
|
-
|
3187
|
-
if (!inited) {
|
3188
|
-
lua_pushlightuserdata(L, &ngx_http_lua_coroutines_key);
|
3189
|
-
lua_rawget(L, LUA_REGISTRYINDEX);
|
3190
|
-
inited = 1;
|
3191
|
-
}
|
3192
|
-
|
3193
|
-
ngx_http_lua_assert(lua_gettop(L) - top == 1);
|
3194
|
-
|
3195
|
-
luaL_unref(L, -1, coctx->co_ref);
|
3196
|
-
coctx->co_ref = LUA_NOREF;
|
3197
|
-
coctx->co_status = NGX_HTTP_LUA_CO_DEAD;
|
3198
|
-
}
|
3199
|
-
|
3200
|
-
if (inited) {
|
3201
|
-
lua_pop(L, 1);
|
3202
|
-
}
|
3203
|
-
}
|
3204
|
-
|
3205
|
-
|
3206
|
-
static ngx_int_t
|
3207
|
-
ngx_http_lua_post_zombie_thread(ngx_http_request_t *r,
|
3208
|
-
ngx_http_lua_co_ctx_t *parent, ngx_http_lua_co_ctx_t *thread)
|
3209
|
-
{
|
3210
|
-
ngx_http_lua_posted_thread_t **p;
|
3211
|
-
ngx_http_lua_posted_thread_t *pt;
|
3212
|
-
|
3213
|
-
pt = ngx_palloc(r->pool, sizeof(ngx_http_lua_posted_thread_t));
|
3214
|
-
if (pt == NULL) {
|
3215
|
-
return NGX_ERROR;
|
3216
|
-
}
|
3217
|
-
|
3218
|
-
pt->co_ctx = thread;
|
3219
|
-
pt->next = NULL;
|
3220
|
-
|
3221
|
-
for (p = &parent->zombie_child_threads; *p; p = &(*p)->next) { /* void */ }
|
3222
|
-
|
3223
|
-
*p = pt;
|
3224
|
-
|
3225
|
-
return NGX_OK;
|
3226
|
-
}
|
3227
|
-
|
3228
|
-
|
3229
|
-
static void
|
3230
|
-
ngx_http_lua_cleanup_zombie_child_uthreads(ngx_http_request_t *r,
|
3231
|
-
lua_State *L, ngx_http_lua_ctx_t *ctx, ngx_http_lua_co_ctx_t *coctx)
|
3232
|
-
{
|
3233
|
-
ngx_http_lua_posted_thread_t *pt;
|
3234
|
-
|
3235
|
-
for (pt = coctx->zombie_child_threads; pt; pt = pt->next) {
|
3236
|
-
if (pt->co_ctx->co_ref != LUA_NOREF) {
|
3237
|
-
ngx_http_lua_del_thread(r, L, ctx, pt->co_ctx);
|
3238
|
-
ctx->uthreads--;
|
3239
|
-
}
|
3240
|
-
}
|
3241
|
-
|
3242
|
-
coctx->zombie_child_threads = NULL;
|
3243
|
-
}
|
3244
|
-
|
3245
|
-
|
3246
|
-
ngx_int_t
|
3247
|
-
ngx_http_lua_check_broken_connection(ngx_http_request_t *r, ngx_event_t *ev)
|
3248
|
-
{
|
3249
|
-
int n;
|
3250
|
-
char buf[1];
|
3251
|
-
ngx_err_t err;
|
3252
|
-
ngx_int_t event;
|
3253
|
-
ngx_connection_t *c;
|
3254
|
-
|
3255
|
-
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, ev->log, 0,
|
3256
|
-
"http lua check client, write event:%d, \"%V\"",
|
3257
|
-
ev->write, &r->uri);
|
3258
|
-
|
3259
|
-
c = r->connection;
|
3260
|
-
|
3261
|
-
if (c->error) {
|
3262
|
-
if ((ngx_event_flags & NGX_USE_LEVEL_EVENT) && ev->active) {
|
3263
|
-
|
3264
|
-
event = ev->write ? NGX_WRITE_EVENT : NGX_READ_EVENT;
|
3265
|
-
|
3266
|
-
if (ngx_del_event(ev, event, 0) != NGX_OK) {
|
3267
|
-
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
3268
|
-
}
|
3269
|
-
}
|
3270
|
-
|
3271
|
-
return NGX_HTTP_CLIENT_CLOSED_REQUEST;
|
3272
|
-
}
|
3273
|
-
|
3274
|
-
#if (NGX_HAVE_KQUEUE)
|
3275
|
-
|
3276
|
-
if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
|
3277
|
-
|
3278
|
-
if (!ev->pending_eof) {
|
3279
|
-
return NGX_OK;
|
3280
|
-
}
|
3281
|
-
|
3282
|
-
ev->eof = 1;
|
3283
|
-
|
3284
|
-
if (ev->kq_errno) {
|
3285
|
-
ev->error = 1;
|
3286
|
-
}
|
3287
|
-
|
3288
|
-
ngx_log_error(NGX_LOG_INFO, ev->log, ev->kq_errno,
|
3289
|
-
"kevent() reported that client prematurely closed "
|
3290
|
-
"connection");
|
3291
|
-
|
3292
|
-
return NGX_HTTP_CLIENT_CLOSED_REQUEST;
|
3293
|
-
}
|
3294
|
-
|
3295
|
-
#endif
|
3296
|
-
|
3297
|
-
n = recv(c->fd, buf, 1, MSG_PEEK);
|
3298
|
-
|
3299
|
-
err = ngx_socket_errno;
|
3300
|
-
|
3301
|
-
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ev->log, err,
|
3302
|
-
"http lua recv(): %d", n);
|
3303
|
-
|
3304
|
-
if (ev->write && (n >= 0 || err == NGX_EAGAIN)) {
|
3305
|
-
return NGX_OK;
|
3306
|
-
}
|
3307
|
-
|
3308
|
-
if ((ngx_event_flags & NGX_USE_LEVEL_EVENT) && ev->active) {
|
3309
|
-
dd("event is active");
|
3310
|
-
|
3311
|
-
event = ev->write ? NGX_WRITE_EVENT : NGX_READ_EVENT;
|
3312
|
-
|
3313
|
-
#if 1
|
3314
|
-
if (ngx_del_event(ev, event, 0) != NGX_OK) {
|
3315
|
-
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
3316
|
-
}
|
3317
|
-
#endif
|
3318
|
-
}
|
3319
|
-
|
3320
|
-
dd("HERE %d", (int) n);
|
3321
|
-
|
3322
|
-
if (n > 0) {
|
3323
|
-
return NGX_OK;
|
3324
|
-
}
|
3325
|
-
|
3326
|
-
if (n == -1) {
|
3327
|
-
if (err == NGX_EAGAIN) {
|
3328
|
-
dd("HERE");
|
3329
|
-
return NGX_OK;
|
3330
|
-
}
|
3331
|
-
|
3332
|
-
ev->error = 1;
|
3333
|
-
|
3334
|
-
} else { /* n == 0 */
|
3335
|
-
err = 0;
|
3336
|
-
}
|
3337
|
-
|
3338
|
-
ev->eof = 1;
|
3339
|
-
|
3340
|
-
ngx_log_error(NGX_LOG_INFO, ev->log, err,
|
3341
|
-
"client prematurely closed connection");
|
3342
|
-
|
3343
|
-
return NGX_HTTP_CLIENT_CLOSED_REQUEST;
|
3344
|
-
}
|
3345
|
-
|
3346
|
-
|
3347
|
-
void
|
3348
|
-
ngx_http_lua_rd_check_broken_connection(ngx_http_request_t *r)
|
3349
|
-
{
|
3350
|
-
ngx_int_t rc;
|
3351
|
-
ngx_event_t *rev;
|
3352
|
-
ngx_http_lua_ctx_t *ctx;
|
3353
|
-
|
3354
|
-
if (r->done) {
|
3355
|
-
return;
|
3356
|
-
}
|
3357
|
-
|
3358
|
-
rc = ngx_http_lua_check_broken_connection(r, r->connection->read);
|
3359
|
-
|
3360
|
-
if (rc == NGX_OK) {
|
3361
|
-
return;
|
3362
|
-
}
|
3363
|
-
|
3364
|
-
/* rc == NGX_ERROR || rc > NGX_OK */
|
3365
|
-
|
3366
|
-
ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module);
|
3367
|
-
if (ctx == NULL) {
|
3368
|
-
return;
|
3369
|
-
}
|
3370
|
-
|
3371
|
-
if (ctx->on_abort_co_ctx == NULL) {
|
3372
|
-
r->connection->error = 1;
|
3373
|
-
ngx_http_lua_request_cleanup(ctx, 0);
|
3374
|
-
ngx_http_lua_finalize_request(r, rc);
|
3375
|
-
return;
|
3376
|
-
}
|
3377
|
-
|
3378
|
-
if (ctx->on_abort_co_ctx->co_status != NGX_HTTP_LUA_CO_SUSPENDED) {
|
3379
|
-
|
3380
|
-
/* on_abort already run for the current request handler */
|
3381
|
-
|
3382
|
-
rev = r->connection->read;
|
3383
|
-
|
3384
|
-
if ((ngx_event_flags & NGX_USE_LEVEL_EVENT) && rev->active) {
|
3385
|
-
if (ngx_del_event(rev, NGX_READ_EVENT, 0) != NGX_OK) {
|
3386
|
-
ngx_http_lua_request_cleanup(ctx, 0);
|
3387
|
-
ngx_http_lua_finalize_request(r,
|
3388
|
-
NGX_HTTP_INTERNAL_SERVER_ERROR);
|
3389
|
-
return;
|
3390
|
-
}
|
3391
|
-
}
|
3392
|
-
|
3393
|
-
return;
|
3394
|
-
}
|
3395
|
-
|
3396
|
-
ctx->uthreads++;
|
3397
|
-
ctx->resume_handler = ngx_http_lua_on_abort_resume;
|
3398
|
-
ctx->on_abort_co_ctx->co_status = NGX_HTTP_LUA_CO_RUNNING;
|
3399
|
-
ctx->cur_co_ctx = ctx->on_abort_co_ctx;
|
3400
|
-
|
3401
|
-
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
3402
|
-
"lua waking up the on_abort callback thread");
|
3403
|
-
|
3404
|
-
if (ctx->entered_content_phase) {
|
3405
|
-
r->write_event_handler = ngx_http_lua_content_wev_handler;
|
3406
|
-
|
3407
|
-
} else {
|
3408
|
-
r->write_event_handler = ngx_http_core_run_phases;
|
3409
|
-
}
|
3410
|
-
|
3411
|
-
r->write_event_handler(r);
|
3412
|
-
}
|
3413
|
-
|
3414
|
-
|
3415
|
-
static ngx_int_t
|
3416
|
-
ngx_http_lua_on_abort_resume(ngx_http_request_t *r)
|
3417
|
-
{
|
3418
|
-
lua_State *vm;
|
3419
|
-
ngx_int_t rc;
|
3420
|
-
ngx_connection_t *c;
|
3421
|
-
ngx_http_lua_ctx_t *ctx;
|
3422
|
-
|
3423
|
-
ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module);
|
3424
|
-
if (ctx == NULL) {
|
3425
|
-
return NGX_ERROR;
|
3426
|
-
}
|
3427
|
-
|
3428
|
-
ctx->resume_handler = ngx_http_lua_wev_handler;
|
3429
|
-
|
3430
|
-
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
3431
|
-
"lua resuming the on_abort callback thread");
|
3432
|
-
|
3433
|
-
#if 0
|
3434
|
-
ngx_http_lua_probe_info("tcp resume");
|
3435
|
-
#endif
|
3436
|
-
|
3437
|
-
c = r->connection;
|
3438
|
-
vm = ngx_http_lua_get_lua_vm(r, ctx);
|
3439
|
-
|
3440
|
-
rc = ngx_http_lua_run_thread(vm, r, ctx, 0);
|
3441
|
-
|
3442
|
-
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
3443
|
-
"lua run thread returned %d", rc);
|
3444
|
-
|
3445
|
-
if (rc == NGX_AGAIN) {
|
3446
|
-
return ngx_http_lua_run_posted_threads(c, vm, r, ctx);
|
3447
|
-
}
|
3448
|
-
|
3449
|
-
if (rc == NGX_DONE) {
|
3450
|
-
ngx_http_lua_finalize_request(r, NGX_DONE);
|
3451
|
-
return ngx_http_lua_run_posted_threads(c, vm, r, ctx);
|
3452
|
-
}
|
3453
|
-
|
3454
|
-
if (ctx->entered_content_phase) {
|
3455
|
-
ngx_http_lua_finalize_request(r, rc);
|
3456
|
-
return NGX_DONE;
|
3457
|
-
}
|
3458
|
-
|
3459
|
-
return rc;
|
3460
|
-
}
|
3461
|
-
|
3462
|
-
|
3463
|
-
ngx_int_t
|
3464
|
-
ngx_http_lua_test_expect(ngx_http_request_t *r)
|
3465
|
-
{
|
3466
|
-
ngx_int_t n;
|
3467
|
-
ngx_str_t *expect;
|
3468
|
-
|
3469
|
-
if (r->expect_tested
|
3470
|
-
|| r->headers_in.expect == NULL
|
3471
|
-
|| r->http_version < NGX_HTTP_VERSION_11)
|
3472
|
-
{
|
3473
|
-
return NGX_OK;
|
3474
|
-
}
|
3475
|
-
|
3476
|
-
r->expect_tested = 1;
|
3477
|
-
|
3478
|
-
expect = &r->headers_in.expect->value;
|
3479
|
-
|
3480
|
-
if (expect->len != sizeof("100-continue") - 1
|
3481
|
-
|| ngx_strncasecmp(expect->data, (u_char *) "100-continue",
|
3482
|
-
sizeof("100-continue") - 1)
|
3483
|
-
!= 0)
|
3484
|
-
{
|
3485
|
-
return NGX_OK;
|
3486
|
-
}
|
3487
|
-
|
3488
|
-
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
3489
|
-
"send 100 Continue");
|
3490
|
-
|
3491
|
-
n = r->connection->send(r->connection,
|
3492
|
-
(u_char *) "HTTP/1.1 100 Continue" CRLF CRLF,
|
3493
|
-
sizeof("HTTP/1.1 100 Continue" CRLF CRLF) - 1);
|
3494
|
-
|
3495
|
-
if (n == sizeof("HTTP/1.1 100 Continue" CRLF CRLF) - 1) {
|
3496
|
-
return NGX_OK;
|
3497
|
-
}
|
3498
|
-
|
3499
|
-
/* we assume that such small packet should be send successfully */
|
3500
|
-
|
3501
|
-
return NGX_ERROR;
|
3502
|
-
}
|
3503
|
-
|
3504
|
-
|
3505
|
-
void
|
3506
|
-
ngx_http_lua_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
|
3507
|
-
{
|
3508
|
-
ngx_http_lua_ctx_t *ctx;
|
3509
|
-
|
3510
|
-
ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module);
|
3511
|
-
if (ctx && ctx->cur_co_ctx) {
|
3512
|
-
ngx_http_lua_cleanup_pending_operation(ctx->cur_co_ctx);
|
3513
|
-
}
|
3514
|
-
|
3515
|
-
if (r->connection->fd != -1) {
|
3516
|
-
ngx_http_finalize_request(r, rc);
|
3517
|
-
return;
|
3518
|
-
}
|
3519
|
-
|
3520
|
-
ngx_http_lua_finalize_fake_request(r, rc);
|
3521
|
-
}
|
3522
|
-
|
3523
|
-
|
3524
|
-
void
|
3525
|
-
ngx_http_lua_finalize_fake_request(ngx_http_request_t *r, ngx_int_t rc)
|
3526
|
-
{
|
3527
|
-
ngx_connection_t *c;
|
3528
|
-
|
3529
|
-
c = r->connection;
|
3530
|
-
|
3531
|
-
ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
3532
|
-
"http lua finalize fake request: %d, a:%d, c:%d",
|
3533
|
-
rc, r == c->data, r->main->count);
|
3534
|
-
|
3535
|
-
if (rc == NGX_DONE) {
|
3536
|
-
ngx_http_lua_close_fake_request(r);
|
3537
|
-
return;
|
3538
|
-
}
|
3539
|
-
|
3540
|
-
if (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE) {
|
3541
|
-
ngx_http_lua_close_fake_request(r);
|
3542
|
-
return;
|
3543
|
-
}
|
3544
|
-
|
3545
|
-
if (c->read->timer_set) {
|
3546
|
-
ngx_del_timer(c->read);
|
3547
|
-
}
|
3548
|
-
|
3549
|
-
if (c->write->timer_set) {
|
3550
|
-
c->write->delayed = 0;
|
3551
|
-
ngx_del_timer(c->write);
|
3552
|
-
}
|
3553
|
-
|
3554
|
-
ngx_http_lua_close_fake_request(r);
|
3555
|
-
}
|
3556
|
-
|
3557
|
-
|
3558
|
-
static void
|
3559
|
-
ngx_http_lua_close_fake_request(ngx_http_request_t *r)
|
3560
|
-
{
|
3561
|
-
ngx_connection_t *c;
|
3562
|
-
|
3563
|
-
r = r->main;
|
3564
|
-
c = r->connection;
|
3565
|
-
|
3566
|
-
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
3567
|
-
"http lua fake request count:%d", r->count);
|
3568
|
-
|
3569
|
-
if (r->count == 0) {
|
3570
|
-
ngx_log_error(NGX_LOG_ALERT, c->log, 0, "http lua fake request "
|
3571
|
-
"count is zero");
|
3572
|
-
}
|
3573
|
-
|
3574
|
-
r->count--;
|
3575
|
-
|
3576
|
-
if (r->count) {
|
3577
|
-
return;
|
3578
|
-
}
|
3579
|
-
|
3580
|
-
ngx_http_lua_free_fake_request(r);
|
3581
|
-
ngx_http_lua_close_fake_connection(c);
|
3582
|
-
}
|
3583
|
-
|
3584
|
-
|
3585
|
-
static void
|
3586
|
-
ngx_http_lua_free_fake_request(ngx_http_request_t *r)
|
3587
|
-
{
|
3588
|
-
ngx_log_t *log;
|
3589
|
-
ngx_http_cleanup_t *cln;
|
3590
|
-
|
3591
|
-
log = r->connection->log;
|
3592
|
-
|
3593
|
-
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, log, 0, "http lua close fake "
|
3594
|
-
"request");
|
3595
|
-
|
3596
|
-
if (r->pool == NULL) {
|
3597
|
-
ngx_log_error(NGX_LOG_ALERT, log, 0, "http lua fake request "
|
3598
|
-
"already closed");
|
3599
|
-
return;
|
3600
|
-
}
|
3601
|
-
|
3602
|
-
for (cln = r->cleanup; cln; cln = cln->next) {
|
3603
|
-
if (cln->handler) {
|
3604
|
-
cln->handler(cln->data);
|
3605
|
-
}
|
3606
|
-
}
|
3607
|
-
|
3608
|
-
r->request_line.len = 0;
|
3609
|
-
|
3610
|
-
r->connection->destroyed = 1;
|
3611
|
-
}
|
3612
|
-
|
3613
|
-
|
3614
|
-
void
|
3615
|
-
ngx_http_lua_close_fake_connection(ngx_connection_t *c)
|
3616
|
-
{
|
3617
|
-
ngx_pool_t *pool;
|
3618
|
-
ngx_connection_t *saved_c = NULL;
|
3619
|
-
|
3620
|
-
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
3621
|
-
"http lua close fake http connection");
|
3622
|
-
|
3623
|
-
c->destroyed = 1;
|
3624
|
-
|
3625
|
-
pool = c->pool;
|
3626
|
-
|
3627
|
-
if (c->read->timer_set) {
|
3628
|
-
ngx_del_timer(c->read);
|
3629
|
-
}
|
3630
|
-
|
3631
|
-
if (c->write->timer_set) {
|
3632
|
-
ngx_del_timer(c->write);
|
3633
|
-
}
|
3634
|
-
|
3635
|
-
c->read->closed = 1;
|
3636
|
-
c->write->closed = 1;
|
3637
|
-
|
3638
|
-
/* we temporarily use a valid fd (0) to make ngx_free_connection happy */
|
3639
|
-
|
3640
|
-
c->fd = 0;
|
3641
|
-
|
3642
|
-
if (ngx_cycle->files) {
|
3643
|
-
saved_c = ngx_cycle->files[0];
|
3644
|
-
}
|
3645
|
-
|
3646
|
-
ngx_free_connection(c);
|
3647
|
-
|
3648
|
-
c->fd = (ngx_socket_t) -1;
|
3649
|
-
|
3650
|
-
if (ngx_cycle->files) {
|
3651
|
-
ngx_cycle->files[0] = saved_c;
|
3652
|
-
}
|
3653
|
-
|
3654
|
-
if (pool) {
|
3655
|
-
ngx_destroy_pool(pool);
|
3656
|
-
}
|
3657
|
-
}
|
3658
|
-
|
3659
|
-
|
3660
|
-
lua_State *
|
3661
|
-
ngx_http_lua_init_vm(lua_State *parent_vm, ngx_cycle_t *cycle,
|
3662
|
-
ngx_pool_t *pool, ngx_http_lua_main_conf_t *lmcf, ngx_log_t *log,
|
3663
|
-
ngx_pool_cleanup_t **pcln)
|
3664
|
-
{
|
3665
|
-
lua_State *L;
|
3666
|
-
ngx_uint_t i;
|
3667
|
-
ngx_pool_cleanup_t *cln;
|
3668
|
-
ngx_http_lua_preload_hook_t *hook;
|
3669
|
-
ngx_http_lua_vm_state_t *state;
|
3670
|
-
|
3671
|
-
cln = ngx_pool_cleanup_add(pool, 0);
|
3672
|
-
if (cln == NULL) {
|
3673
|
-
return NULL;
|
3674
|
-
}
|
3675
|
-
|
3676
|
-
/* create new Lua VM instance */
|
3677
|
-
L = ngx_http_lua_new_state(parent_vm, cycle, lmcf, log);
|
3678
|
-
if (L == NULL) {
|
3679
|
-
return NULL;
|
3680
|
-
}
|
3681
|
-
|
3682
|
-
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0, "lua initialize the "
|
3683
|
-
"global Lua VM %p", L);
|
3684
|
-
|
3685
|
-
/* register cleanup handler for Lua VM */
|
3686
|
-
cln->handler = ngx_http_lua_cleanup_vm;
|
3687
|
-
|
3688
|
-
state = ngx_alloc(sizeof(ngx_http_lua_vm_state_t), log);
|
3689
|
-
if (state == NULL) {
|
3690
|
-
return NULL;
|
3691
|
-
}
|
3692
|
-
state->vm = L;
|
3693
|
-
state->count = 1;
|
3694
|
-
|
3695
|
-
cln->data = state;
|
3696
|
-
|
3697
|
-
if (pcln) {
|
3698
|
-
*pcln = cln;
|
3699
|
-
}
|
3700
|
-
|
3701
|
-
if (lmcf->preload_hooks) {
|
3702
|
-
|
3703
|
-
/* register the 3rd-party module's preload hooks */
|
3704
|
-
|
3705
|
-
lua_getglobal(L, "package");
|
3706
|
-
lua_getfield(L, -1, "preload");
|
3707
|
-
|
3708
|
-
hook = lmcf->preload_hooks->elts;
|
3709
|
-
|
3710
|
-
for (i = 0; i < lmcf->preload_hooks->nelts; i++) {
|
3711
|
-
|
3712
|
-
ngx_http_lua_probe_register_preload_package(L, hook[i].package);
|
3713
|
-
|
3714
|
-
lua_pushcfunction(L, hook[i].loader);
|
3715
|
-
lua_setfield(L, -2, (char *) hook[i].package);
|
3716
|
-
}
|
3717
|
-
|
3718
|
-
lua_pop(L, 2);
|
3719
|
-
}
|
3720
|
-
|
3721
|
-
return L;
|
3722
|
-
}
|
3723
|
-
|
3724
|
-
|
3725
|
-
void
|
3726
|
-
ngx_http_lua_cleanup_vm(void *data)
|
3727
|
-
{
|
3728
|
-
lua_State *L;
|
3729
|
-
ngx_http_lua_vm_state_t *state = data;
|
3730
|
-
|
3731
|
-
#if (DDEBUG)
|
3732
|
-
if (state) {
|
3733
|
-
dd("cleanup VM: c:%d, s:%p", (int) state->count, state->vm);
|
3734
|
-
}
|
3735
|
-
#endif
|
3736
|
-
|
3737
|
-
if (state) {
|
3738
|
-
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0, "decrementing "
|
3739
|
-
"the reference count for Lua VM: %i", state->count);
|
3740
|
-
|
3741
|
-
if (--state->count == 0) {
|
3742
|
-
L = state->vm;
|
3743
|
-
ngx_http_lua_cleanup_conn_pools(L);
|
3744
|
-
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,
|
3745
|
-
"lua close the global Lua VM %p", L);
|
3746
|
-
lua_close(L);
|
3747
|
-
ngx_free(state);
|
3748
|
-
}
|
3749
|
-
}
|
3750
|
-
}
|
3751
|
-
|
3752
|
-
|
3753
|
-
ngx_connection_t *
|
3754
|
-
ngx_http_lua_create_fake_connection(ngx_pool_t *pool)
|
3755
|
-
{
|
3756
|
-
ngx_log_t *log;
|
3757
|
-
ngx_connection_t *c;
|
3758
|
-
ngx_connection_t *saved_c = NULL;
|
3759
|
-
|
3760
|
-
/* (we temporarily use a valid fd (0) to make ngx_get_connection happy) */
|
3761
|
-
if (ngx_cycle->files) {
|
3762
|
-
saved_c = ngx_cycle->files[0];
|
3763
|
-
}
|
3764
|
-
|
3765
|
-
c = ngx_get_connection(0, ngx_cycle->log);
|
3766
|
-
|
3767
|
-
if (ngx_cycle->files) {
|
3768
|
-
ngx_cycle->files[0] = saved_c;
|
3769
|
-
}
|
3770
|
-
|
3771
|
-
if (c == NULL) {
|
3772
|
-
return NULL;
|
3773
|
-
}
|
3774
|
-
|
3775
|
-
c->fd = (ngx_socket_t) -1;
|
3776
|
-
|
3777
|
-
if (pool) {
|
3778
|
-
c->pool = pool;
|
3779
|
-
|
3780
|
-
} else {
|
3781
|
-
c->pool = ngx_create_pool(128, c->log);
|
3782
|
-
if (c->pool == NULL) {
|
3783
|
-
goto failed;
|
3784
|
-
}
|
3785
|
-
}
|
3786
|
-
|
3787
|
-
log = ngx_pcalloc(c->pool, sizeof(ngx_log_t));
|
3788
|
-
if (log == NULL) {
|
3789
|
-
goto failed;
|
3790
|
-
}
|
3791
|
-
|
3792
|
-
c->log = log;
|
3793
|
-
c->log->connection = c->number;
|
3794
|
-
c->log->action = NULL;
|
3795
|
-
c->log->data = NULL;
|
3796
|
-
|
3797
|
-
c->log_error = NGX_ERROR_INFO;
|
3798
|
-
|
3799
|
-
#if 0
|
3800
|
-
c->buffer = ngx_create_temp_buf(c->pool, 2);
|
3801
|
-
if (c->buffer == NULL) {
|
3802
|
-
goto failed;
|
3803
|
-
}
|
3804
|
-
|
3805
|
-
c->buffer->start[0] = CR;
|
3806
|
-
c->buffer->start[1] = LF;
|
3807
|
-
#endif
|
3808
|
-
|
3809
|
-
c->error = 1;
|
3810
|
-
|
3811
|
-
return c;
|
3812
|
-
|
3813
|
-
failed:
|
3814
|
-
|
3815
|
-
ngx_http_lua_close_fake_connection(c);
|
3816
|
-
return NULL;
|
3817
|
-
}
|
3818
|
-
|
3819
|
-
|
3820
|
-
ngx_http_request_t *
|
3821
|
-
ngx_http_lua_create_fake_request(ngx_connection_t *c)
|
3822
|
-
{
|
3823
|
-
ngx_http_request_t *r;
|
3824
|
-
|
3825
|
-
r = ngx_pcalloc(c->pool, sizeof(ngx_http_request_t));
|
3826
|
-
if (r == NULL) {
|
3827
|
-
return NULL;
|
3828
|
-
}
|
3829
|
-
|
3830
|
-
c->requests++;
|
3831
|
-
|
3832
|
-
r->pool = c->pool;
|
3833
|
-
|
3834
|
-
dd("r pool allocated: %d", (int) (sizeof(ngx_http_lua_ctx_t)
|
3835
|
-
+ sizeof(void *) * ngx_http_max_module + sizeof(ngx_http_cleanup_t)));
|
3836
|
-
|
3837
|
-
#if 0
|
3838
|
-
hc = ngx_pcalloc(c->pool, sizeof(ngx_http_connection_t));
|
3839
|
-
if (hc == NULL) {
|
3840
|
-
goto failed;
|
3841
|
-
}
|
3842
|
-
|
3843
|
-
r->header_in = c->buffer;
|
3844
|
-
r->header_end = c->buffer->start;
|
3845
|
-
|
3846
|
-
if (ngx_list_init(&r->headers_out.headers, r->pool, 0,
|
3847
|
-
sizeof(ngx_table_elt_t))
|
3848
|
-
!= NGX_OK)
|
3849
|
-
{
|
3850
|
-
goto failed;
|
3851
|
-
}
|
3852
|
-
|
3853
|
-
if (ngx_list_init(&r->headers_in.headers, r->pool, 0,
|
3854
|
-
sizeof(ngx_table_elt_t))
|
3855
|
-
!= NGX_OK)
|
3856
|
-
{
|
3857
|
-
goto failed;
|
3858
|
-
}
|
3859
|
-
#endif
|
3860
|
-
|
3861
|
-
r->ctx = ngx_pcalloc(r->pool, sizeof(void *) * ngx_http_max_module);
|
3862
|
-
if (r->ctx == NULL) {
|
3863
|
-
return NULL;
|
3864
|
-
}
|
3865
|
-
|
3866
|
-
#if 0
|
3867
|
-
cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
|
3868
|
-
|
3869
|
-
r->variables = ngx_pcalloc(r->pool, cmcf->variables.nelts
|
3870
|
-
* sizeof(ngx_http_variable_value_t));
|
3871
|
-
if (r->variables == NULL) {
|
3872
|
-
goto failed;
|
3873
|
-
}
|
3874
|
-
#endif
|
3875
|
-
|
3876
|
-
r->connection = c;
|
3877
|
-
|
3878
|
-
r->headers_in.content_length_n = 0;
|
3879
|
-
c->data = r;
|
3880
|
-
#if 0
|
3881
|
-
hc->request = r;
|
3882
|
-
r->http_connection = hc;
|
3883
|
-
#endif
|
3884
|
-
r->signature = NGX_HTTP_MODULE;
|
3885
|
-
r->main = r;
|
3886
|
-
r->count = 1;
|
3887
|
-
|
3888
|
-
r->method = NGX_HTTP_UNKNOWN;
|
3889
|
-
|
3890
|
-
r->headers_in.keep_alive_n = -1;
|
3891
|
-
r->uri_changes = NGX_HTTP_MAX_URI_CHANGES + 1;
|
3892
|
-
r->subrequests = NGX_HTTP_MAX_SUBREQUESTS + 1;
|
3893
|
-
|
3894
|
-
r->http_state = NGX_HTTP_PROCESS_REQUEST_STATE;
|
3895
|
-
r->discard_body = 1;
|
3896
|
-
|
3897
|
-
return r;
|
3898
|
-
}
|
3899
|
-
|
3900
|
-
|
3901
|
-
ngx_int_t
|
3902
|
-
ngx_http_lua_report(ngx_log_t *log, lua_State *L, int status,
|
3903
|
-
const char *prefix)
|
3904
|
-
{
|
3905
|
-
const char *msg;
|
3906
|
-
|
3907
|
-
if (status && !lua_isnil(L, -1)) {
|
3908
|
-
msg = lua_tostring(L, -1);
|
3909
|
-
if (msg == NULL) {
|
3910
|
-
msg = "unknown error";
|
3911
|
-
}
|
3912
|
-
|
3913
|
-
ngx_log_error(NGX_LOG_ERR, log, 0, "%s error: %s", prefix, msg);
|
3914
|
-
lua_pop(L, 1);
|
3915
|
-
}
|
3916
|
-
|
3917
|
-
/* force a full garbage-collection cycle */
|
3918
|
-
lua_gc(L, LUA_GCCOLLECT, 0);
|
3919
|
-
|
3920
|
-
return status == 0 ? NGX_OK : NGX_ERROR;
|
3921
|
-
}
|
3922
|
-
|
3923
|
-
|
3924
|
-
int
|
3925
|
-
ngx_http_lua_do_call(ngx_log_t *log, lua_State *L)
|
3926
|
-
{
|
3927
|
-
int status, base;
|
3928
|
-
#if (NGX_PCRE)
|
3929
|
-
ngx_pool_t *old_pool;
|
3930
|
-
#endif
|
3931
|
-
|
3932
|
-
base = lua_gettop(L); /* function index */
|
3933
|
-
lua_pushcfunction(L, ngx_http_lua_traceback); /* push traceback function */
|
3934
|
-
lua_insert(L, base); /* put it under chunk and args */
|
3935
|
-
|
3936
|
-
#if (NGX_PCRE)
|
3937
|
-
old_pool = ngx_http_lua_pcre_malloc_init(ngx_cycle->pool);
|
3938
|
-
#endif
|
3939
|
-
|
3940
|
-
status = lua_pcall(L, 0, 0, base);
|
3941
|
-
|
3942
|
-
#if (NGX_PCRE)
|
3943
|
-
ngx_http_lua_pcre_malloc_done(old_pool);
|
3944
|
-
#endif
|
3945
|
-
|
3946
|
-
lua_remove(L, base);
|
3947
|
-
|
3948
|
-
return status;
|
3949
|
-
}
|
3950
|
-
|
3951
|
-
|
3952
|
-
static int
|
3953
|
-
ngx_http_lua_get_raw_phase_context(lua_State *L)
|
3954
|
-
{
|
3955
|
-
ngx_http_request_t *r;
|
3956
|
-
ngx_http_lua_ctx_t *ctx;
|
3957
|
-
|
3958
|
-
r = lua_touserdata(L, 1);
|
3959
|
-
if (r == NULL) {
|
3960
|
-
return 0;
|
3961
|
-
}
|
3962
|
-
|
3963
|
-
ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module);
|
3964
|
-
if (ctx == NULL) {
|
3965
|
-
return 0;
|
3966
|
-
}
|
3967
|
-
|
3968
|
-
lua_pushinteger(L, (int) ctx->context);
|
3969
|
-
return 1;
|
3970
|
-
}
|
3971
|
-
|
3972
|
-
/* vi:set ft=c ts=4 sw=4 et fdm=marker: */
|