passenger 4.0.30 → 4.0.31

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of passenger might be problematic. Click here for more details.

Files changed (409) hide show
  1. data.tar.gz.asc +7 -7
  2. data/NEWS +31 -0
  3. data/bin/passenger +5 -5
  4. data/bin/passenger-config +6 -126
  5. data/bin/passenger-install-apache2-module +108 -26
  6. data/bin/passenger-install-nginx-module +81 -27
  7. data/bin/passenger-memory-stats +7 -6
  8. data/bin/passenger-status +13 -10
  9. data/build/agents.rb +8 -12
  10. data/build/apache2.rb +12 -7
  11. data/build/basics.rb +28 -20
  12. data/build/common_library.rb +4 -4
  13. data/build/cplusplus_support.rb +4 -4
  14. data/build/cxx_tests.rb +5 -3
  15. data/build/debian.rb +1 -2
  16. data/build/integration_tests.rb +25 -9
  17. data/build/misc.rb +2 -2
  18. data/build/oxt_tests.rb +5 -6
  19. data/build/packaging.rb +72 -40
  20. data/build/ruby_tests.rb +5 -1
  21. data/build/test_basics.rb +1 -2
  22. data/debian.template/locations.ini.template +1 -0
  23. data/debian.template/rules.template +2 -1
  24. data/dev/install_scripts_bootstrap_code.rb +42 -0
  25. data/dev/run_travis.sh +1 -0
  26. data/dev/runner +27 -0
  27. data/doc/Packaging.txt.md +5 -10
  28. data/doc/Users guide Apache.idmap.txt +3 -1
  29. data/doc/Users guide Apache.txt +5 -3
  30. data/doc/Users guide Nginx.idmap.txt +9 -5
  31. data/doc/Users guide Nginx.txt +47 -17
  32. data/doc/users_guide_snippets/environment_variables.txt +2 -2
  33. data/doc/users_guide_snippets/installation.txt +6 -2
  34. data/doc/users_guide_snippets/tips.txt +4 -0
  35. data/ext/apache2/Hooks.cpp +16 -3
  36. data/ext/common/Account.h +6 -5
  37. data/ext/common/AgentsStarter.h +1 -1
  38. data/ext/common/ApplicationPool2/Common.h +72 -0
  39. data/ext/common/ApplicationPool2/Group.h +263 -148
  40. data/ext/common/ApplicationPool2/Implementation.cpp +66 -44
  41. data/ext/common/ApplicationPool2/Options.h +1 -7
  42. data/ext/common/ApplicationPool2/Pool.h +96 -72
  43. data/ext/common/ApplicationPool2/Process.h +12 -17
  44. data/ext/common/ApplicationPool2/Socket.h +4 -4
  45. data/ext/common/ApplicationPool2/SuperGroup.h +20 -17
  46. data/ext/common/Constants.h +15 -1
  47. data/ext/common/MessageServer.h +22 -0
  48. data/ext/common/Utils.cpp +4 -1
  49. data/ext/common/Utils.h +3 -1
  50. data/ext/common/Utils/StrIntUtils.h +1 -0
  51. data/ext/common/Utils/Timer.h +15 -1
  52. data/ext/common/Utils/utf8/checked.h +0 -0
  53. data/ext/common/Utils/utf8/core.h +0 -0
  54. data/ext/common/Utils/utf8/unchecked.h +0 -0
  55. data/ext/common/agents/Base.cpp +59 -35
  56. data/ext/common/agents/HelperAgent/Main.cpp +23 -12
  57. data/ext/common/agents/HelperAgent/RequestHandler.h +10 -1
  58. data/ext/common/agents/LoggingAgent/FilterSupport.h +9 -5
  59. data/ext/common/agents/TempDirToucher.c +12 -3
  60. data/ext/common/agents/Watchdog/Main.cpp +8 -2
  61. data/ext/nginx/ConfigurationCommands.c +10 -0
  62. data/ext/nginx/ConfigurationFields.h +2 -0
  63. data/ext/nginx/ContentHandler.c +32 -19
  64. data/ext/nginx/CreateLocationConfig.c +5 -0
  65. data/ext/nginx/MergeLocationConfig.c +6 -0
  66. data/ext/nginx/config +13 -6
  67. data/ext/ruby/passenger_native_support.c +61 -2
  68. data/helper-scripts/classic-rails-loader.rb +9 -10
  69. data/helper-scripts/classic-rails-preloader.rb +10 -11
  70. data/helper-scripts/node-loader.js +3 -2
  71. data/helper-scripts/rack-loader.rb +8 -9
  72. data/helper-scripts/rack-preloader.rb +9 -10
  73. data/lib/phusion_passenger.rb +36 -7
  74. data/lib/phusion_passenger/abstract_installer.rb +16 -15
  75. data/lib/phusion_passenger/active_support3_extensions/init.rb +1 -1
  76. data/lib/phusion_passenger/admin_tools/memory_stats.rb +2 -2
  77. data/lib/phusion_passenger/admin_tools/server_instance.rb +5 -5
  78. data/lib/phusion_passenger/analytics_logger.rb +3 -3
  79. data/lib/phusion_passenger/classic_rails/thread_handler_extension.rb +1 -1
  80. data/lib/phusion_passenger/config.rb +125 -0
  81. data/lib/phusion_passenger/config/about_command.rb +183 -0
  82. data/lib/phusion_passenger/config/command.rb +57 -0
  83. data/lib/phusion_passenger/config/restart_app_command.rb +146 -0
  84. data/lib/phusion_passenger/config/utils.rb +108 -0
  85. data/lib/phusion_passenger/console_text_template.rb +2 -1
  86. data/lib/phusion_passenger/constants.rb +7 -2
  87. data/lib/phusion_passenger/loader_shared_helpers.rb +12 -21
  88. data/lib/phusion_passenger/message_client.rb +15 -4
  89. data/lib/phusion_passenger/native_support.rb +116 -98
  90. data/lib/phusion_passenger/nginx/config_options.rb +5 -0
  91. data/lib/phusion_passenger/platform_info.rb +1 -1
  92. data/lib/phusion_passenger/platform_info/apache.rb +9 -5
  93. data/lib/phusion_passenger/platform_info/apache_detector.rb +5 -6
  94. data/lib/phusion_passenger/platform_info/binary_compatibility.rb +3 -3
  95. data/lib/phusion_passenger/platform_info/compiler.rb +29 -11
  96. data/lib/phusion_passenger/platform_info/curl.rb +1 -1
  97. data/lib/phusion_passenger/platform_info/cxx_portability.rb +30 -16
  98. data/lib/phusion_passenger/platform_info/depcheck.rb +6 -6
  99. data/lib/phusion_passenger/platform_info/linux.rb +2 -2
  100. data/lib/phusion_passenger/platform_info/operating_system.rb +25 -5
  101. data/lib/phusion_passenger/platform_info/ruby.rb +7 -4
  102. data/lib/phusion_passenger/platform_info/zlib.rb +1 -1
  103. data/lib/phusion_passenger/plugin.rb +0 -1
  104. data/lib/phusion_passenger/preloader_shared_helpers.rb +1 -1
  105. data/lib/phusion_passenger/public_api.rb +1 -1
  106. data/lib/phusion_passenger/rack/thread_handler_extension.rb +1 -1
  107. data/lib/phusion_passenger/request_handler.rb +8 -9
  108. data/lib/phusion_passenger/request_handler/thread_handler.rb +21 -9
  109. data/lib/phusion_passenger/ruby_core_enhancements.rb +1 -1
  110. data/lib/phusion_passenger/standalone/app_finder.rb +2 -2
  111. data/lib/phusion_passenger/standalone/command.rb +10 -8
  112. data/lib/phusion_passenger/standalone/help_command.rb +1 -1
  113. data/lib/phusion_passenger/standalone/main.rb +3 -3
  114. data/lib/phusion_passenger/standalone/package_runtime_command.rb +2 -2
  115. data/lib/phusion_passenger/standalone/runtime_installer.rb +55 -13
  116. data/lib/phusion_passenger/standalone/runtime_locator.rb +3 -3
  117. data/lib/phusion_passenger/standalone/start_command.rb +6 -7
  118. data/lib/phusion_passenger/standalone/status_command.rb +1 -1
  119. data/lib/phusion_passenger/standalone/stop_command.rb +1 -1
  120. data/lib/phusion_passenger/standalone/utils.rb +1 -1
  121. data/lib/phusion_passenger/standalone/version_command.rb +2 -3
  122. data/lib/phusion_passenger/utils.rb +1 -1
  123. data/lib/phusion_passenger/utils/download.rb +1 -2
  124. data/lib/phusion_passenger/utils/file_system_watcher.rb +1 -1
  125. data/lib/phusion_passenger/utils/hosts_file_parser.rb +1 -1
  126. data/lib/phusion_passenger/utils/tee_input.rb +1 -1
  127. data/lib/phusion_passenger/utils/terminal_choice_menu.rb +217 -0
  128. data/lib/phusion_passenger/utils/unseekable_socket.rb +1 -1
  129. data/resources/templates/apache2/config_snippets.txt.erb +2 -3
  130. data/resources/templates/apache2/deployment_example.txt.erb +2 -2
  131. data/resources/templates/apache2/notify_apache_module_installed.txt.erb +3 -0
  132. data/resources/templates/nginx/config_snippets.txt.erb +1 -1
  133. data/resources/templates/nginx/deployment_example.txt.erb +2 -2
  134. data/resources/templates/nginx/nginx_module_sources_not_available.txt.erb +11 -5
  135. data/rpm/Vagrantfile +1 -0
  136. data/test/cxx/ApplicationPool2/PoolTest.cpp +224 -35
  137. data/test/cxx/ApplicationPool2/ProcessTest.cpp +6 -6
  138. data/test/cxx/MessagePassingTest.cpp +1 -1
  139. data/test/cxx/RequestHandlerTest.cpp +26 -26
  140. data/test/integration_tests/apache2_tests.rb +162 -243
  141. data/test/integration_tests/native_packaging_spec.rb +10 -10
  142. data/test/integration_tests/nginx_tests.rb +87 -107
  143. data/test/integration_tests/shared/example_webapp_tests.rb +246 -0
  144. data/test/integration_tests/source_packaging_test.rb +2 -1
  145. data/test/integration_tests/standalone_tests.rb +34 -19
  146. data/test/ruby/admin_tools_spec.rb +4 -4
  147. data/test/ruby/analytics_logger_spec.rb +1 -1
  148. data/test/ruby/debug_logging_spec.rb +2 -2
  149. data/test/ruby/message_channel_spec.rb +1 -1
  150. data/test/ruby/request_handler_spec.rb +171 -64
  151. data/test/ruby/shared/loader_sharedspec.rb +5 -5
  152. data/test/ruby/shared/rails/analytics_logging_extensions_sharedspec.rb +2 -2
  153. data/test/ruby/spec_helper.rb +4 -4
  154. data/test/ruby/standalone/runtime_installer_spec.rb +1 -1
  155. data/test/ruby/standalone/runtime_locator_spec.rb +1 -1
  156. data/test/ruby/utils/file_system_watcher_spec.rb +1 -1
  157. data/test/ruby/utils/hosts_file_parser.rb +1 -1
  158. data/test/ruby/utils/unseekable_socket_spec.rb +1 -1
  159. data/test/ruby/utils_spec.rb +4 -4
  160. data/test/stub/apache2/httpd.conf.erb +5 -0
  161. data/test/stub/index.html +1 -0
  162. data/test/stub/rack/config.ru +80 -33
  163. data/test/stub/{rails_apps/1.2/empty/app/models → rack/public}/.gitignore +0 -0
  164. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/Rakefile +0 -0
  165. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/controllers/application_controller.rb +0 -0
  166. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/controllers/recipes_controller.rb +0 -0
  167. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/controllers/uploads_controller.rb +0 -0
  168. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/controllers/welcome_controller.rb +0 -0
  169. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/app/helpers/application_helper.rb +0 -0
  170. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/helpers/recipes_helper.rb +0 -0
  171. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/helpers/test_helper.rb +0 -0
  172. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/helpers/uploads_helper.rb +0 -0
  173. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/helpers/welcome_helper.rb +0 -0
  174. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/views/layouts/default.rhtml +0 -0
  175. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/views/recipes/create.rhtml +0 -0
  176. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/views/recipes/index.rhtml +0 -0
  177. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/views/recipes/new.rhtml +0 -0
  178. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/views/uploads/index.rhtml +0 -0
  179. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/views/uploads/new.html.erb +0 -0
  180. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/views/welcome/cached.rhtml +0 -0
  181. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/app/views/welcome/index.rhtml +0 -0
  182. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/config/boot.rb +0 -0
  183. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/config/database.yml +0 -0
  184. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/config/environment.rb +0 -0
  185. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/config/environments/development.rb +0 -0
  186. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/config/environments/production.rb +0 -0
  187. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/config/initializers/inflections.rb +0 -0
  188. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/config/initializers/mime_types.rb +0 -0
  189. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/config/routes.rb +0 -0
  190. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/log/useless.txt +0 -0
  191. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/public/.htaccess +0 -0
  192. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/public/404.html +0 -0
  193. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/public/422.html +0 -0
  194. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/public/500.html +0 -0
  195. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/public/dispatch.cgi +0 -0
  196. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/public/dispatch.fcgi +0 -0
  197. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/public/dispatch.rb +0 -0
  198. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/public/favicon.ico +0 -0
  199. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/public/images/angrywizard.gif +0 -0
  200. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/public/images/cookbook.gif +0 -0
  201. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/public/images/header.png +0 -0
  202. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/public/images/rails.png +0 -0
  203. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/public/robots.txt +0 -0
  204. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/public/uploads.html +0 -0
  205. data/test/stub/{rails_apps/1.2/empty/db → rails2.3-mycook/public/uploads}/.gitignore +0 -0
  206. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/public/welcome/cached.html +0 -0
  207. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/script/about +0 -0
  208. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/script/console +0 -0
  209. data/test/stub/{rails_apps/2.2/empty → rails2.3-mycook}/script/dbconsole +0 -0
  210. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/script/destroy +0 -0
  211. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/script/generate +0 -0
  212. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/script/performance/benchmarker +0 -0
  213. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/script/performance/profiler +0 -0
  214. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/script/performance/request +0 -0
  215. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/script/plugin +0 -0
  216. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/script/process/inspector +0 -0
  217. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/script/process/reaper +0 -0
  218. data/test/stub/{rails_apps/1.2/empty → rails2.3-mycook}/script/process/spawner +0 -0
  219. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/script/runner +0 -0
  220. data/test/stub/{rails_apps/2.0/empty → rails2.3-mycook}/script/server +0 -0
  221. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/sites/some.site/public/uploads.html +0 -0
  222. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/sites/some.site/public/welcome/cached.html +0 -0
  223. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/tmp/cache/useless.txt +0 -0
  224. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/tmp/pids/useless.txt +0 -0
  225. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/tmp/sessions/useless.txt +0 -0
  226. data/test/stub/{rails_apps/2.3/mycook → rails2.3-mycook}/tmp/sockets/useless.txt +0 -0
  227. data/test/stub/rails2.3/app/controllers/foo_controller.rb +1 -1
  228. data/test/stub/rails2.3/config/routes.rb +1 -2
  229. data/test/stub/wsgi/passenger_wsgi.py +47 -8
  230. data/test/stub/{rails_apps/1.2/empty/public/stylesheets → wsgi/public}/.gitignore +0 -0
  231. data/test/support/apache2_controller.rb +2 -2
  232. data/test/support/nginx_controller.rb +11 -5
  233. data/test/support/placebo-preloader.rb +2 -2
  234. data/test/support/test_helper.rb +26 -7
  235. metadata +78 -240
  236. metadata.gz.asc +7 -7
  237. data/debian.template/repack.sh +0 -42
  238. data/debian.template/watch +0 -3
  239. data/test/integration_tests/cgi_environment_spec.rb +0 -36
  240. data/test/integration_tests/hello_world_rack_spec.rb +0 -43
  241. data/test/integration_tests/hello_world_wsgi_spec.rb +0 -41
  242. data/test/integration_tests/mycook_spec.rb +0 -166
  243. data/test/stub/rack/public/rack.jpg +0 -0
  244. data/test/stub/rails_apps/1.2/empty/.gitignore +0 -3
  245. data/test/stub/rails_apps/1.2/empty/app/controllers/application.rb +0 -7
  246. data/test/stub/rails_apps/1.2/empty/config/boot.rb +0 -108
  247. data/test/stub/rails_apps/1.2/empty/config/database.yml +0 -31
  248. data/test/stub/rails_apps/1.2/empty/config/environment.rb +0 -66
  249. data/test/stub/rails_apps/1.2/empty/config/environments/development.rb +0 -21
  250. data/test/stub/rails_apps/1.2/empty/config/environments/production.rb +0 -18
  251. data/test/stub/rails_apps/1.2/empty/config/environments/staging.rb +0 -18
  252. data/test/stub/rails_apps/1.2/empty/config/environments/test.rb +0 -19
  253. data/test/stub/rails_apps/1.2/empty/config/routes.rb +0 -23
  254. data/test/stub/rails_apps/1.2/empty/doc/README_FOR_APP +0 -2
  255. data/test/stub/rails_apps/1.2/empty/public/.htaccess +0 -40
  256. data/test/stub/rails_apps/1.2/empty/public/500.html +0 -30
  257. data/test/stub/rails_apps/1.2/empty/public/dispatch.cgi +0 -10
  258. data/test/stub/rails_apps/1.2/empty/public/dispatch.fcgi +0 -24
  259. data/test/stub/rails_apps/1.2/empty/public/dispatch.rb +0 -10
  260. data/test/stub/rails_apps/1.2/empty/public/robots.txt +0 -1
  261. data/test/stub/rails_apps/1.2/empty/script/about +0 -3
  262. data/test/stub/rails_apps/1.2/empty/script/breakpointer +0 -3
  263. data/test/stub/rails_apps/1.2/empty/script/console +0 -3
  264. data/test/stub/rails_apps/1.2/empty/script/destroy +0 -3
  265. data/test/stub/rails_apps/1.2/empty/script/generate +0 -3
  266. data/test/stub/rails_apps/1.2/empty/script/plugin +0 -3
  267. data/test/stub/rails_apps/1.2/empty/script/runner +0 -3
  268. data/test/stub/rails_apps/1.2/empty/script/server +0 -3
  269. data/test/stub/rails_apps/1.2/empty/test/test_helper.rb +0 -28
  270. data/test/stub/rails_apps/2.0/empty/.gitignore +0 -3
  271. data/test/stub/rails_apps/2.0/empty/Rakefile +0 -10
  272. data/test/stub/rails_apps/2.0/empty/app/controllers/application.rb +0 -10
  273. data/test/stub/rails_apps/2.0/empty/app/helpers/application_helper.rb +0 -3
  274. data/test/stub/rails_apps/2.0/empty/app/models/.gitignore +0 -0
  275. data/test/stub/rails_apps/2.0/empty/config/boot.rb +0 -108
  276. data/test/stub/rails_apps/2.0/empty/config/database.yml +0 -31
  277. data/test/stub/rails_apps/2.0/empty/config/environment.rb +0 -59
  278. data/test/stub/rails_apps/2.0/empty/config/environments/production.rb +0 -18
  279. data/test/stub/rails_apps/2.0/empty/config/environments/staging.rb +0 -18
  280. data/test/stub/rails_apps/2.0/empty/config/environments/test.rb +0 -22
  281. data/test/stub/rails_apps/2.0/empty/config/routes.rb +0 -35
  282. data/test/stub/rails_apps/2.0/empty/db/.gitignore +0 -0
  283. data/test/stub/rails_apps/2.0/empty/doc/README_FOR_APP +0 -2
  284. data/test/stub/rails_apps/2.0/empty/public/.htaccess +0 -40
  285. data/test/stub/rails_apps/2.0/empty/public/404.html +0 -30
  286. data/test/stub/rails_apps/2.0/empty/public/dispatch.cgi +0 -10
  287. data/test/stub/rails_apps/2.0/empty/public/dispatch.fcgi +0 -24
  288. data/test/stub/rails_apps/2.0/empty/public/dispatch.rb +0 -10
  289. data/test/stub/rails_apps/2.0/empty/public/favicon.ico +0 -0
  290. data/test/stub/rails_apps/2.0/empty/public/images/rails.png +0 -0
  291. data/test/stub/rails_apps/2.0/empty/public/stylesheets/.gitignore +0 -0
  292. data/test/stub/rails_apps/2.0/empty/script/performance/benchmarker +0 -3
  293. data/test/stub/rails_apps/2.0/empty/script/performance/profiler +0 -3
  294. data/test/stub/rails_apps/2.0/empty/script/process/inspector +0 -3
  295. data/test/stub/rails_apps/2.0/empty/script/process/reaper +0 -3
  296. data/test/stub/rails_apps/2.0/empty/script/process/spawner +0 -3
  297. data/test/stub/rails_apps/2.0/empty/test/test_helper.rb +0 -38
  298. data/test/stub/rails_apps/2.2/empty/.gitignore +0 -3
  299. data/test/stub/rails_apps/2.2/empty/Rakefile +0 -10
  300. data/test/stub/rails_apps/2.2/empty/app/controllers/application.rb +0 -15
  301. data/test/stub/rails_apps/2.2/empty/app/helpers/application_helper.rb +0 -3
  302. data/test/stub/rails_apps/2.2/empty/app/models/.gitignore +0 -0
  303. data/test/stub/rails_apps/2.2/empty/config/boot.rb +0 -109
  304. data/test/stub/rails_apps/2.2/empty/config/database.yml +0 -31
  305. data/test/stub/rails_apps/2.2/empty/config/environment.rb +0 -75
  306. data/test/stub/rails_apps/2.2/empty/config/environments/development.rb +0 -17
  307. data/test/stub/rails_apps/2.2/empty/config/environments/production.rb +0 -24
  308. data/test/stub/rails_apps/2.2/empty/config/environments/staging.rb +0 -24
  309. data/test/stub/rails_apps/2.2/empty/config/environments/test.rb +0 -22
  310. data/test/stub/rails_apps/2.2/empty/config/initializers/inflections.rb +0 -10
  311. data/test/stub/rails_apps/2.2/empty/config/initializers/mime_types.rb +0 -5
  312. data/test/stub/rails_apps/2.2/empty/config/initializers/new_rails_defaults.rb +0 -17
  313. data/test/stub/rails_apps/2.2/empty/config/locales/en.yml +0 -5
  314. data/test/stub/rails_apps/2.2/empty/config/routes.rb +0 -43
  315. data/test/stub/rails_apps/2.2/empty/db/.gitignore +0 -0
  316. data/test/stub/rails_apps/2.2/empty/doc/README_FOR_APP +0 -5
  317. data/test/stub/rails_apps/2.2/empty/public/404.html +0 -30
  318. data/test/stub/rails_apps/2.2/empty/public/422.html +0 -30
  319. data/test/stub/rails_apps/2.2/empty/public/500.html +0 -33
  320. data/test/stub/rails_apps/2.2/empty/public/dispatch.cgi +0 -10
  321. data/test/stub/rails_apps/2.2/empty/public/dispatch.fcgi +0 -24
  322. data/test/stub/rails_apps/2.2/empty/public/dispatch.rb +0 -10
  323. data/test/stub/rails_apps/2.2/empty/public/favicon.ico +0 -0
  324. data/test/stub/rails_apps/2.2/empty/public/images/rails.png +0 -0
  325. data/test/stub/rails_apps/2.2/empty/public/robots.txt +0 -5
  326. data/test/stub/rails_apps/2.2/empty/public/stylesheets/.gitignore +0 -0
  327. data/test/stub/rails_apps/2.2/empty/script/about +0 -4
  328. data/test/stub/rails_apps/2.2/empty/script/console +0 -3
  329. data/test/stub/rails_apps/2.2/empty/script/destroy +0 -3
  330. data/test/stub/rails_apps/2.2/empty/script/generate +0 -3
  331. data/test/stub/rails_apps/2.2/empty/script/performance/benchmarker +0 -3
  332. data/test/stub/rails_apps/2.2/empty/script/performance/profiler +0 -3
  333. data/test/stub/rails_apps/2.2/empty/script/performance/request +0 -3
  334. data/test/stub/rails_apps/2.2/empty/script/plugin +0 -3
  335. data/test/stub/rails_apps/2.2/empty/script/process/inspector +0 -3
  336. data/test/stub/rails_apps/2.2/empty/script/process/reaper +0 -3
  337. data/test/stub/rails_apps/2.2/empty/script/process/spawner +0 -3
  338. data/test/stub/rails_apps/2.2/empty/script/runner +0 -3
  339. data/test/stub/rails_apps/2.2/empty/script/server +0 -3
  340. data/test/stub/rails_apps/2.2/empty/test/performance/browsing_test.rb +0 -9
  341. data/test/stub/rails_apps/2.2/empty/test/test_helper.rb +0 -38
  342. data/test/stub/rails_apps/2.3/empty/.gitignore +0 -3
  343. data/test/stub/rails_apps/2.3/empty/Rakefile +0 -10
  344. data/test/stub/rails_apps/2.3/empty/app/controllers/application_controller.rb +0 -10
  345. data/test/stub/rails_apps/2.3/empty/app/helpers/application_helper.rb +0 -3
  346. data/test/stub/rails_apps/2.3/empty/app/models/.gitignore +0 -0
  347. data/test/stub/rails_apps/2.3/empty/config/boot.rb +0 -110
  348. data/test/stub/rails_apps/2.3/empty/config/database.yml +0 -31
  349. data/test/stub/rails_apps/2.3/empty/config/environment.rb +0 -41
  350. data/test/stub/rails_apps/2.3/empty/config/environments/development.rb +0 -17
  351. data/test/stub/rails_apps/2.3/empty/config/environments/production.rb +0 -28
  352. data/test/stub/rails_apps/2.3/empty/config/environments/staging.rb +0 -28
  353. data/test/stub/rails_apps/2.3/empty/config/environments/test.rb +0 -28
  354. data/test/stub/rails_apps/2.3/empty/config/initializers/backtrace_silencers.rb +0 -7
  355. data/test/stub/rails_apps/2.3/empty/config/initializers/inflections.rb +0 -10
  356. data/test/stub/rails_apps/2.3/empty/config/initializers/mime_types.rb +0 -5
  357. data/test/stub/rails_apps/2.3/empty/config/initializers/new_rails_defaults.rb +0 -21
  358. data/test/stub/rails_apps/2.3/empty/config/initializers/session_store.rb +0 -15
  359. data/test/stub/rails_apps/2.3/empty/config/locales/en.yml +0 -5
  360. data/test/stub/rails_apps/2.3/empty/config/routes.rb +0 -43
  361. data/test/stub/rails_apps/2.3/empty/db/.gitignore +0 -0
  362. data/test/stub/rails_apps/2.3/empty/db/seeds.rb +0 -7
  363. data/test/stub/rails_apps/2.3/empty/doc/README_FOR_APP +0 -2
  364. data/test/stub/rails_apps/2.3/empty/public/404.html +0 -30
  365. data/test/stub/rails_apps/2.3/empty/public/422.html +0 -30
  366. data/test/stub/rails_apps/2.3/empty/public/500.html +0 -30
  367. data/test/stub/rails_apps/2.3/empty/public/favicon.ico +0 -0
  368. data/test/stub/rails_apps/2.3/empty/public/images/rails.png +0 -0
  369. data/test/stub/rails_apps/2.3/empty/public/robots.txt +0 -5
  370. data/test/stub/rails_apps/2.3/empty/public/stylesheets/.gitignore +0 -0
  371. data/test/stub/rails_apps/2.3/empty/script/about +0 -4
  372. data/test/stub/rails_apps/2.3/empty/script/console +0 -3
  373. data/test/stub/rails_apps/2.3/empty/script/dbconsole +0 -3
  374. data/test/stub/rails_apps/2.3/empty/script/destroy +0 -3
  375. data/test/stub/rails_apps/2.3/empty/script/generate +0 -3
  376. data/test/stub/rails_apps/2.3/empty/script/performance/benchmarker +0 -3
  377. data/test/stub/rails_apps/2.3/empty/script/performance/profiler +0 -3
  378. data/test/stub/rails_apps/2.3/empty/script/plugin +0 -3
  379. data/test/stub/rails_apps/2.3/empty/script/runner +0 -3
  380. data/test/stub/rails_apps/2.3/empty/script/server +0 -3
  381. data/test/stub/rails_apps/2.3/empty/test/performance/browsing_test.rb +0 -9
  382. data/test/stub/rails_apps/2.3/empty/test/test_helper.rb +0 -38
  383. data/test/stub/rails_apps/2.3/mycook/Rakefile +0 -10
  384. data/test/stub/rails_apps/2.3/mycook/app/helpers/application_helper.rb +0 -3
  385. data/test/stub/rails_apps/2.3/mycook/config/environments/development.rb +0 -18
  386. data/test/stub/rails_apps/2.3/mycook/config/initializers/inflections.rb +0 -10
  387. data/test/stub/rails_apps/2.3/mycook/config/initializers/mime_types.rb +0 -5
  388. data/test/stub/rails_apps/2.3/mycook/public/404.html +0 -30
  389. data/test/stub/rails_apps/2.3/mycook/public/422.html +0 -30
  390. data/test/stub/rails_apps/2.3/mycook/public/500.html +0 -30
  391. data/test/stub/rails_apps/2.3/mycook/public/favicon.ico +0 -0
  392. data/test/stub/rails_apps/2.3/mycook/public/images/rails.png +0 -0
  393. data/test/stub/rails_apps/2.3/mycook/public/robots.txt +0 -5
  394. data/test/stub/rails_apps/2.3/mycook/public/uploads/.gitignore +0 -0
  395. data/test/stub/rails_apps/2.3/mycook/script/about +0 -3
  396. data/test/stub/rails_apps/2.3/mycook/script/console +0 -3
  397. data/test/stub/rails_apps/2.3/mycook/script/dbconsole +0 -3
  398. data/test/stub/rails_apps/2.3/mycook/script/destroy +0 -3
  399. data/test/stub/rails_apps/2.3/mycook/script/generate +0 -3
  400. data/test/stub/rails_apps/2.3/mycook/script/performance/benchmarker +0 -3
  401. data/test/stub/rails_apps/2.3/mycook/script/performance/profiler +0 -3
  402. data/test/stub/rails_apps/2.3/mycook/script/performance/request +0 -3
  403. data/test/stub/rails_apps/2.3/mycook/script/plugin +0 -3
  404. data/test/stub/rails_apps/2.3/mycook/script/process/inspector +0 -3
  405. data/test/stub/rails_apps/2.3/mycook/script/process/reaper +0 -3
  406. data/test/stub/rails_apps/2.3/mycook/script/process/spawner +0 -3
  407. data/test/stub/rails_apps/2.3/mycook/script/runner +0 -3
  408. data/test/stub/rails_apps/2.3/mycook/script/server +0 -3
  409. data/test/stub/wsgi/public/wsgi-snake.jpg +0 -0
@@ -139,7 +139,7 @@ private:
139
139
  boost::weak_ptr<Group> group;
140
140
 
141
141
  /** A subset of 'sockets': all sockets that speak the
142
- * "session" protocol, sorted by socket.utilization(). */
142
+ * "session" protocol, sorted by socket.busyness(). */
143
143
  PriorityQueue<Socket> sessionSockets;
144
144
 
145
145
  /** The iterator inside the associated Group's process list. */
@@ -181,7 +181,7 @@ private:
181
181
  for (it = sockets->begin(); it != sockets->end(); it++) {
182
182
  Socket *socket = &(*it);
183
183
  if (socket->protocol == "session" || socket->protocol == "http_session") {
184
- socket->pqHandle = sessionSockets.push(socket, socket->utilization());
184
+ socket->pqHandle = sessionSockets.push(socket, socket->busyness());
185
185
  if (concurrency != -1) {
186
186
  if (socket->concurrency == 0) {
187
187
  // If one of the sockets has a concurrency of
@@ -516,13 +516,13 @@ public:
516
516
  }
517
517
  }
518
518
 
519
- int utilization() const {
519
+ int busyness() const {
520
520
  /* Different processes within a Group may have different
521
521
  * 'concurrency' values. We want:
522
522
  * - Group.pqueue to sort the processes from least used to most used.
523
523
  * - to give processes with concurrency == 0 more priority over processes
524
524
  * with concurrency > 0.
525
- * Therefore, we describe our utilization as a percentage of 'concurrency', with
525
+ * Therefore, we describe our busyness as a percentage of 'concurrency', with
526
526
  * the percentage value in [0..INT_MAX] instead of [0..1].
527
527
  */
528
528
  if (concurrency == 0) {
@@ -537,26 +537,21 @@ public:
537
537
  }
538
538
  }
539
539
 
540
- // TODO: remove this
541
- bool atFullCapacity() const {
542
- return atFullUtilization();
543
- }
544
-
545
540
  /**
546
541
  * Whether we've reached the maximum number of concurrent sessions for this
547
542
  * process.
548
543
  */
549
- bool atFullUtilization() const {
544
+ bool isTotallyBusy() const {
550
545
  return concurrency != 0 && sessions >= concurrency;
551
546
  }
552
547
 
553
548
  /**
554
549
  * Whether a get() request can be routed to this process, assuming that
555
550
  * the sticky session ID (if any) matches. This is only not the case
556
- * if this process is at full utilization.
551
+ * if this process is totally busy.
557
552
  */
558
553
  bool canBeRoutedTo() const {
559
- return !atFullUtilization();
554
+ return !isTotallyBusy();
560
555
  }
561
556
 
562
557
  /**
@@ -570,12 +565,12 @@ public:
570
565
  */
571
566
  SessionPtr newSession() {
572
567
  Socket *socket = sessionSockets.pop();
573
- if (socket->atFullCapacity()) {
568
+ if (socket->isTotallyBusy()) {
574
569
  return SessionPtr();
575
570
  } else {
576
571
  socket->sessions++;
577
572
  this->sessions++;
578
- socket->pqHandle = sessionSockets.push(socket, socket->utilization());
573
+ socket->pqHandle = sessionSockets.push(socket, socket->busyness());
579
574
  lastUsed = SystemTime::getUsec();
580
575
  return boost::make_shared<Session>(shared_from_this(), socket);
581
576
  }
@@ -590,8 +585,8 @@ public:
590
585
  socket->sessions--;
591
586
  this->sessions--;
592
587
  processed++;
593
- sessionSockets.decrease(socket->pqHandle, socket->utilization());
594
- assert(!atFullUtilization());
588
+ sessionSockets.decrease(socket->pqHandle, socket->busyness());
589
+ assert(!isTotallyBusy());
595
590
  }
596
591
 
597
592
  /**
@@ -611,7 +606,7 @@ public:
611
606
  stream << "<connect_password>" << connectPassword << "</connect_password>";
612
607
  stream << "<concurrency>" << concurrency << "</concurrency>";
613
608
  stream << "<sessions>" << sessions << "</sessions>";
614
- stream << "<utilization>" << utilization() << "</utilization>";
609
+ stream << "<busyness>" << busyness() << "</busyness>";
615
610
  stream << "<processed>" << processed << "</processed>";
616
611
  stream << "<spawner_creation_time>" << spawnerCreationTime << "</spawner_creation_time>";
617
612
  stream << "<spawn_start_time>" << spawnStartTime << "</spawn_start_time>";
@@ -179,17 +179,17 @@ public:
179
179
  }
180
180
 
181
181
 
182
- bool idle() const {
182
+ bool isIdle() const {
183
183
  return sessions == 0;
184
184
  }
185
185
 
186
- int utilization() const {
186
+ int busyness() const {
187
187
  /* Different sockets within a Process may have different
188
188
  * 'concurrency' values. We want:
189
189
  * - Process.sessionSockets to sort the sockets from least used to most used.
190
190
  * - to give sockets with concurrency == 0 more priority over sockets
191
191
  * with concurrency > 0.
192
- * Therefore, we describe our utilization as a percentage of 'concurrency', with
192
+ * Therefore, we describe our busyness as a percentage of 'concurrency', with
193
193
  * the percentage value in [0..INT_MAX] instead of [0..1].
194
194
  */
195
195
  if (concurrency == 0) {
@@ -205,7 +205,7 @@ public:
205
205
  }
206
206
  }
207
207
 
208
- bool atFullCapacity() const {
208
+ bool isTotallyBusy() const {
209
209
  return concurrency != 0 && sessions >= concurrency;
210
210
  }
211
211
  };
@@ -297,7 +297,8 @@ private:
297
297
  Group *group = route(waiter.options);
298
298
  Options adjustedOptions = waiter.options;
299
299
  adjustOptions(adjustedOptions, group);
300
- SessionPtr session = group->get(adjustedOptions, waiter.callback);
300
+ SessionPtr session = group->get(adjustedOptions, waiter.callback,
301
+ postLockActions);
301
302
  if (session != NULL) {
302
303
  postLockActions.push_back(boost::bind(
303
304
  waiter.callback, session, ExceptionPtr()));
@@ -573,7 +574,9 @@ public:
573
574
  return false;
574
575
  }
575
576
 
576
- SessionPtr get(const Options &newOptions, const GetCallback &callback) {
577
+ SessionPtr get(const Options &newOptions, const GetCallback &callback,
578
+ vector<Callback> &postLockActions)
579
+ {
577
580
  switch (state) {
578
581
  case INITIALIZING:
579
582
  getWaitlist.push_back(GetWaiter(newOptions, callback));
@@ -589,10 +592,10 @@ public:
589
592
  Options adjustedOptions = newOptions;
590
593
  adjustOptions(adjustedOptions, group);
591
594
  verifyInvariants();
592
- return group->get(adjustedOptions, callback);
595
+ return group->get(adjustedOptions, callback, postLockActions);
593
596
  } else {
594
597
  verifyInvariants();
595
- return defaultGroup->get(newOptions, callback);
598
+ return defaultGroup->get(newOptions, callback, postLockActions);
596
599
  }
597
600
  case DESTROYING:
598
601
  case DESTROYED:
@@ -618,19 +621,29 @@ public:
618
621
  return defaultGroup;
619
622
  }
620
623
 
621
- unsigned int utilization() const {
624
+ unsigned int capacityUsed() const {
622
625
  vector<GroupPtr>::const_iterator it, end = groups.end();
623
626
  unsigned int result = 0;
624
627
 
625
628
  for (it = groups.begin(); it != end; it++) {
626
- result += (*it)->utilization();
629
+ result += (*it)->capacityUsed();
627
630
  }
628
631
  if (state == INITIALIZING || state == RESTARTING) {
629
632
  result++;
630
633
  }
631
634
  return result;
632
635
  }
633
-
636
+
637
+ unsigned int getProcessCount() const {
638
+ unsigned int result = 0;
639
+ vector<GroupPtr>::const_iterator g_it, g_end = groups.end();
640
+ for (g_it = groups.begin(); g_it != g_end; g_it++) {
641
+ const GroupPtr &group = *g_it;
642
+ result += group->getProcessCount();
643
+ }
644
+ return result;
645
+ }
646
+
634
647
  bool needsRestart() const {
635
648
  return false;
636
649
  }
@@ -652,16 +665,6 @@ public:
652
665
  verifyInvariants();
653
666
  }
654
667
 
655
- unsigned int getProcessCount() const {
656
- unsigned int result = 0;
657
- vector<GroupPtr>::const_iterator g_it, g_end = groups.end();
658
- for (g_it = groups.begin(); g_it != g_end; g_it++) {
659
- const GroupPtr &group = *g_it;
660
- result += group->getProcessCount();
661
- }
662
- return result;
663
- }
664
-
665
668
  string inspect() const {
666
669
  return name;
667
670
  }
@@ -38,6 +38,12 @@
38
38
 
39
39
  #define APACHE2_DOC_URL "http://www.modrails.com/documentation/Users%20guide%20Apache.html"
40
40
 
41
+ #define DEB_APACHE_MODULE_PACKAGE "libapache2-mod-passenger"
42
+
43
+ #define DEB_DEV_PACKAGE "passenger-dev"
44
+
45
+ #define DEB_NGINX_PACKAGE "nginx-extras"
46
+
41
47
  #define DEFAULT_ANALYTICS_LOG_GROUP ""
42
48
 
43
49
  #define DEFAULT_ANALYTICS_LOG_PERMISSIONS "u=rwx,g=rx,o=rx"
@@ -68,6 +74,8 @@
68
74
 
69
75
  #define DEFAULT_WEB_APP_USER "nobody"
70
76
 
77
+ #define ENTERPRISE_URL "http://www.phusionpassenger.com/enterprise"
78
+
71
79
  #define FEEDBACK_FD 3
72
80
 
73
81
  #define INDEX_DOC_URL "http://www.modrails.com/documentation/Users%20guide.html"
@@ -78,7 +86,7 @@
78
86
 
79
87
  #define NGINX_DOC_URL "http://www.modrails.com/documentation/Users%20guide%20Nginx.html"
80
88
 
81
- #define PASSENGER_VERSION "4.0.30"
89
+ #define PASSENGER_VERSION "4.0.31"
82
90
 
83
91
  #define POOL_HELPER_THREAD_STACK_SIZE 262144
84
92
 
@@ -88,6 +96,12 @@
88
96
 
89
97
  #define PROGRAM_NAME "Phusion Passenger"
90
98
 
99
+ #define RPM_APACHE_MODULE_PACKAGE "mod_passenger"
100
+
101
+ #define RPM_DEV_PACKAGE "passenger-devel"
102
+
103
+ #define RPM_NGINX_PACKAGE "nginx"
104
+
91
105
  #define SERVER_INSTANCE_DIR_GENERATION_STRUCTURE_MAJOR_VERSION 3
92
106
 
93
107
  #define SERVER_INSTANCE_DIR_GENERATION_STRUCTURE_MINOR_VERSION 0
@@ -49,6 +49,7 @@
49
49
  #include <Utils/StrIntUtils.h>
50
50
  #include <Utils/IOUtils.h>
51
51
  #include <Utils/MessageIO.h>
52
+ #include <Utils/VariantMap.h>
52
53
 
53
54
  namespace Passenger {
54
55
 
@@ -247,6 +248,27 @@ public:
247
248
  return args.size() >= minargs + 1 && args.size() <= maxargs + 1 && args[0] == command;
248
249
  }
249
250
 
251
+ /** Utility function for converting arguments (starting from the given index)
252
+ * into a VariantMap.
253
+ *
254
+ * @throws ArgumentException The number of arguments isn't an even number.
255
+ */
256
+ VariantMap argsToOptions(const vector<string> &args, unsigned int startIndex = 1) const {
257
+ VariantMap map;
258
+ vector<string>::const_iterator it = args.begin() + startIndex, end = args.end();
259
+ while (it != end) {
260
+ const string &key = *it;
261
+ it++;
262
+ if (it == end) {
263
+ throw ArgumentException("Invalid options");
264
+ }
265
+ const string &value = *it;
266
+ map.set(key, value);
267
+ it++;
268
+ }
269
+ return map;
270
+ }
271
+
250
272
  public:
251
273
  virtual ~Handler() { }
252
274
 
@@ -540,7 +540,10 @@ absolutizePath(const StaticString &path, const StaticString &workingDir) {
540
540
  if (!startsWith(path, "/")) {
541
541
  if (workingDir.empty()) {
542
542
  char buffer[PATH_MAX];
543
- getcwd(buffer, sizeof(buffer));
543
+ if (getcwd(buffer, sizeof(buffer)) == NULL) {
544
+ int e = errno;
545
+ throw SystemException("Unable to query current working directory", e);
546
+ }
544
547
  split(buffer + 1, '/', components);
545
548
  } else {
546
549
  string absoluteWorkingDir = absolutizePath(workingDir);
@@ -249,8 +249,10 @@ mode_t parseModeString(const StaticString &mode);
249
249
  /**
250
250
  * Turns the given path into an absolute path. Unlike realpath(), this function does
251
251
  * not resolve symlinks.
252
+ *
253
+ * @throws SystemException
252
254
  */
253
- string absolutizePath(const StaticString &path, const StaticString &workingDir = "");
255
+ string absolutizePath(const StaticString &path, const StaticString &workingDir = StaticString());
254
256
 
255
257
  /**
256
258
  * Return the path name for the directory in which the system stores general
@@ -30,6 +30,7 @@
30
30
  #include <sstream>
31
31
  #include <stdexcept>
32
32
  #include <new>
33
+ #include <cstdlib>
33
34
  #include <cstddef>
34
35
  #include <ctime>
35
36
  #include <oxt/macros.hpp>
@@ -91,7 +91,21 @@ public:
91
91
  startTime.tv_sec = 0;
92
92
  startTime.tv_usec = 0;
93
93
  }
94
-
94
+
95
+ /**
96
+ * Resets the timer. If the timer was already started then it is still started;
97
+ * if it was stopped then it is still stopped.
98
+ */
99
+ void reset() {
100
+ boost::lock_guard<boost::mutex> l(lock);
101
+ if (startTime.tv_sec != 0 || startTime.tv_usec != 0) {
102
+ int ret;
103
+ do {
104
+ ret = gettimeofday(&startTime, NULL);
105
+ } while (ret == -1 && errno == EINTR);
106
+ }
107
+ }
108
+
95
109
  /**
96
110
  * Returns the amount of time that has elapsed since the timer was last started,
97
111
  * in miliseconds. If the timer is currently stopped, then 0 is returned.
File without changes
File without changes
File without changes
@@ -85,6 +85,13 @@ struct AbortHandlerState {
85
85
  typedef void (*Callback)(AbortHandlerState &state, void *userData);
86
86
 
87
87
 
88
+ #define IGNORE_SYSCALL_RESULT(code) \
89
+ do { \
90
+ int _ret = code; \
91
+ (void) _ret; \
92
+ } while (false)
93
+
94
+
88
95
  static bool _feedbackFdAvailable = false;
89
96
  static const char digits[] = {
90
97
  '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
@@ -150,6 +157,15 @@ hasEnvOption(const char *name, bool defaultValue = false) {
150
157
  }
151
158
  }
152
159
 
160
+ // When we're in a crash handler, there's nothing we can do if we fail to
161
+ // write to stderr, so we ignore its return value and we ignore compiler
162
+ // warnings about ignoring that.
163
+ static void
164
+ write_nowarn(int fd, const void *buf, size_t n) {
165
+ ssize_t ret = write(fd, buf, n);
166
+ (void) ret;
167
+ }
168
+
153
169
  // No idea whether strlen() is async signal safe, but let's not risk it
154
170
  // and write our own version instead that's guaranteed to be safe.
155
171
  static size_t
@@ -165,7 +181,7 @@ safeStrlen(const char *str) {
165
181
  // Async-signal safe way to print to stderr.
166
182
  static void
167
183
  safePrintErr(const char *message) {
168
- write(STDERR_FILENO, message, strlen(message));
184
+ write_nowarn(STDERR_FILENO, message, strlen(message));
169
185
  }
170
186
 
171
187
  // Must be async signal safe.
@@ -369,7 +385,7 @@ runInSubprocessWithTimeLimit(AbortHandlerState &state, Callback callback, void *
369
385
  end = appendText(end, "Could not create subprocess: pipe() failed with errno=");
370
386
  end = appendULL(end, e);
371
387
  end = appendText(end, "\n");
372
- write(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
388
+ write_nowarn(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
373
389
  return -1;
374
390
  }
375
391
 
@@ -388,7 +404,7 @@ runInSubprocessWithTimeLimit(AbortHandlerState &state, Callback callback, void *
388
404
  end = appendText(end, "Could not create subprocess: fork() failed with errno=");
389
405
  end = appendULL(end, e);
390
406
  end = appendText(end, "\n");
391
- write(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
407
+ write_nowarn(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
392
408
  return -1;
393
409
 
394
410
  } else {
@@ -430,7 +446,7 @@ dumpFileDescriptorInfoWithLsof(AbortHandlerState &state, void *userData) {
430
446
  end = appendText(end, "ERROR: cannot execute command 'lsof': errno=");
431
447
  end = appendULL(end, errno);
432
448
  end = appendText(end, "\n");
433
- write(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
449
+ write_nowarn(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
434
450
  _exit(1);
435
451
  }
436
452
 
@@ -462,7 +478,7 @@ dumpFileDescriptorInfo(AbortHandlerState &state) {
462
478
  end = messageBuf;
463
479
  end = appendText(end, state.messagePrefix);
464
480
  end = appendText(end, " ] Open files and file descriptors:\n");
465
- write(STDERR_FILENO, messageBuf, end - messageBuf);
481
+ write_nowarn(STDERR_FILENO, messageBuf, end - messageBuf);
466
482
 
467
483
  status = runInSubprocessWithTimeLimit(state, dumpFileDescriptorInfoWithLsof, NULL, 4000);
468
484
 
@@ -485,7 +501,7 @@ dumpFileDescriptorInfo(AbortHandlerState &state) {
485
501
  } else {
486
502
  end = messageBuf;
487
503
  end = appendText(end, "ERROR: No other file descriptor dumping mechanism on current platform detected.\n");
488
- write(STDERR_FILENO, messageBuf, end - messageBuf);
504
+ write_nowarn(STDERR_FILENO, messageBuf, end - messageBuf);
489
505
  }
490
506
  }
491
507
  }
@@ -513,7 +529,7 @@ dumpWithCrashWatch(AbortHandlerState &state) {
513
529
  end = appendText(end, "(execlp() returned errno=");
514
530
  end = appendULL(end, e);
515
531
  end = appendText(end, ") Please check your file permissions or something.\n");
516
- write(STDERR_FILENO, messageBuf, end - messageBuf);
532
+ write_nowarn(STDERR_FILENO, messageBuf, end - messageBuf);
517
533
  }
518
534
  _exit(1);
519
535
 
@@ -523,7 +539,7 @@ dumpWithCrashWatch(AbortHandlerState &state) {
523
539
  end = appendText(end, "Could not execute crash-watch: fork() failed with errno=");
524
540
  end = appendULL(end, e);
525
541
  end = appendText(end, "\n");
526
- write(STDERR_FILENO, messageBuf, end - messageBuf);
542
+ write_nowarn(STDERR_FILENO, messageBuf, end - messageBuf);
527
543
 
528
544
  } else {
529
545
  waitpid(child, NULL, 0);
@@ -542,7 +558,7 @@ dumpWithCrashWatch(AbortHandlerState &state) {
542
558
  end = appendText(end, " ] Backtrace with ");
543
559
  end = appendULL(end, (unsigned long long) frames);
544
560
  end = appendText(end, " frames:\n");
545
- write(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
561
+ write_nowarn(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
546
562
 
547
563
  if (backtraceSanitizerCommand != NULL) {
548
564
  int p[2];
@@ -553,7 +569,7 @@ dumpWithCrashWatch(AbortHandlerState &state) {
553
569
  end = appendULL(end, e);
554
570
  end = appendText(end, "\n");
555
571
  end = appendText(end, "Falling back to writing to stderr directly...\n");
556
- write(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
572
+ write_nowarn(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
557
573
  backtrace_symbols_fd(backtraceStore, frames, STDERR_FILENO);
558
574
  return;
559
575
  }
@@ -586,7 +602,7 @@ dumpWithCrashWatch(AbortHandlerState &state) {
586
602
  end = appendText(end, "ERROR: cannot execute '");
587
603
  end = appendText(end, backtraceSanitizerCommand);
588
604
  end = appendText(end, "' for sanitizing the backtrace, trying 'cat'...\n");
589
- write(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
605
+ write_nowarn(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
590
606
  execlp("cat", "cat", (const char * const) 0);
591
607
  execlp("/bin/cat", "cat", (const char * const) 0);
592
608
  execlp("/usr/bin/cat", "cat", (const char * const) 0);
@@ -602,7 +618,7 @@ dumpWithCrashWatch(AbortHandlerState &state) {
602
618
  end = appendULL(end, e);
603
619
  end = appendText(end, "\n");
604
620
  end = appendText(end, "Falling back to writing to stderr directly...\n");
605
- write(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
621
+ write_nowarn(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
606
622
  backtrace_symbols_fd(backtraceStore, frames, STDERR_FILENO);
607
623
 
608
624
  } else {
@@ -616,7 +632,7 @@ dumpWithCrashWatch(AbortHandlerState &state) {
616
632
  end = appendText(end, "ERROR: cannot execute '");
617
633
  end = appendText(end, backtraceSanitizerCommand);
618
634
  end = appendText(end, "' for sanitizing the backtrace, writing to stderr directly...\n");
619
- write(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
635
+ write_nowarn(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
620
636
  backtrace_symbols_fd(backtraceStore, frames, STDERR_FILENO);
621
637
  }
622
638
  }
@@ -643,7 +659,7 @@ dumpDiagnostics(AbortHandlerState &state) {
643
659
  end = messageBuf;
644
660
  end = appendText(end, state.messagePrefix);
645
661
  end = appendText(end, " ] Date, uname and ulimits:\n");
646
- write(STDERR_FILENO, messageBuf, end - messageBuf);
662
+ write_nowarn(STDERR_FILENO, messageBuf, end - messageBuf);
647
663
 
648
664
  // Dump human-readable time string and string.
649
665
  pid = asyncFork();
@@ -686,7 +702,7 @@ dumpDiagnostics(AbortHandlerState &state) {
686
702
  end = messageBuf;
687
703
  end = appendText(end, state.messagePrefix);
688
704
  end = appendText(end, " ] Phusion Passenger version: " PASSENGER_VERSION "\n");
689
- write(STDERR_FILENO, messageBuf, end - messageBuf);
705
+ write_nowarn(STDERR_FILENO, messageBuf, end - messageBuf);
690
706
 
691
707
  if (lastAssertionFailure.filename != NULL) {
692
708
  end = messageBuf;
@@ -704,7 +720,7 @@ dumpDiagnostics(AbortHandlerState &state) {
704
720
  end = appendText(end, ", line ");
705
721
  end = appendULL(end, lastAssertionFailure.line);
706
722
  end = appendText(end, ".\n");
707
- write(STDERR_FILENO, messageBuf, end - messageBuf);
723
+ write_nowarn(STDERR_FILENO, messageBuf, end - messageBuf);
708
724
  }
709
725
 
710
726
  // It is important that writing the message and the backtrace are two
@@ -717,7 +733,7 @@ dumpDiagnostics(AbortHandlerState &state) {
717
733
  #else
718
734
  end = appendText(end, " ] libc backtrace not available.\n");
719
735
  #endif
720
- write(STDERR_FILENO, messageBuf, end - messageBuf);
736
+ write_nowarn(STDERR_FILENO, messageBuf, end - messageBuf);
721
737
 
722
738
  #ifdef LIBC_HAS_BACKTRACE_FUNC
723
739
  runInSubprocessWithTimeLimit(state, dumpBacktrace, NULL, 4000);
@@ -729,7 +745,7 @@ dumpDiagnostics(AbortHandlerState &state) {
729
745
  end = messageBuf;
730
746
  end = appendText(end, state.messagePrefix);
731
747
  end = appendText(end, " ] Dumping additional diagnostical information...\n");
732
- write(STDERR_FILENO, messageBuf, end - messageBuf);
748
+ write_nowarn(STDERR_FILENO, messageBuf, end - messageBuf);
733
749
  safePrintErr("--------------------------------------\n");
734
750
  runInSubprocessWithTimeLimit(state, runCustomDiagnosticsDumper, NULL, 2000);
735
751
  safePrintErr("--------------------------------------\n");
@@ -746,10 +762,10 @@ dumpDiagnostics(AbortHandlerState &state) {
746
762
  #else
747
763
  end = appendText(end, " ] Dumping a backtrace with crash-watch...\n");
748
764
  #endif
749
- write(STDERR_FILENO, messageBuf, end - messageBuf);
765
+ write_nowarn(STDERR_FILENO, messageBuf, end - messageBuf);
750
766
  dumpWithCrashWatch(state);
751
767
  } else {
752
- write(STDERR_FILENO, "\n", 1);
768
+ write_nowarn(STDERR_FILENO, "\n", 1);
753
769
  }
754
770
  }
755
771
 
@@ -836,7 +852,7 @@ abortHandler(int signo, siginfo_t *info, void *ctx) {
836
852
  end = appendText(end, ", reason=");
837
853
  end = appendSignalReason(end, state.info);
838
854
  end = appendText(end, "\n");
839
- write(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
855
+ write_nowarn(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
840
856
  // Run default signal handler.
841
857
  raise(signo);
842
858
  } else {
@@ -847,16 +863,24 @@ abortHandler(int signo, siginfo_t *info, void *ctx) {
847
863
  end = appendText(end, ", reason=");
848
864
  end = appendSignalReason(end, state.info);
849
865
  end = appendText(end, "\n");
850
- write(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
866
+ write_nowarn(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
851
867
  _exit(1);
852
868
  }
853
869
  return;
854
870
  }
855
871
 
856
- close(emergencyPipe1[0]);
857
- close(emergencyPipe1[1]);
858
- close(emergencyPipe2[0]);
859
- close(emergencyPipe2[1]);
872
+ if (emergencyPipe1[0] != -1) {
873
+ close(emergencyPipe1[0]);
874
+ }
875
+ if (emergencyPipe1[1] != -1) {
876
+ close(emergencyPipe1[1]);
877
+ }
878
+ if (emergencyPipe2[0] != -1) {
879
+ close(emergencyPipe2[0]);
880
+ }
881
+ if (emergencyPipe2[1] != -1) {
882
+ close(emergencyPipe2[1]);
883
+ }
860
884
  emergencyPipe1[0] = emergencyPipe1[1] = -1;
861
885
  emergencyPipe2[0] = emergencyPipe2[1] = -1;
862
886
 
@@ -883,7 +907,7 @@ abortHandler(int signo, siginfo_t *info, void *ctx) {
883
907
  end = appendText(end, ", randomSeed=");
884
908
  end = appendULL(end, (unsigned long long) randomSeed);
885
909
  end = appendText(end, "\n");
886
- write(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
910
+ write_nowarn(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
887
911
 
888
912
  end = state.messageBuf;
889
913
  if (*crashLogFile != '\0') {
@@ -895,13 +919,13 @@ abortHandler(int signo, siginfo_t *info, void *ctx) {
895
919
  end = appendText(end, state.messagePrefix);
896
920
  end = appendText(end, " ] Could not create crash log file, so dumping to stderr only.\n");
897
921
  }
898
- write(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
922
+ write_nowarn(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
899
923
 
900
924
  if (beepOnAbort) {
901
925
  end = state.messageBuf;
902
926
  end = appendText(end, state.messagePrefix);
903
927
  end = appendText(end, " ] PASSENGER_BEEP_ON_ABORT on, executing beep...\n");
904
- write(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
928
+ write_nowarn(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
905
929
 
906
930
  child = asyncFork();
907
931
  if (child == 0) {
@@ -922,7 +946,7 @@ abortHandler(int signo, siginfo_t *info, void *ctx) {
922
946
  end = appendText(end, " ] Could fork a child process for invoking a beep: fork() failed with errno=");
923
947
  end = appendULL(end, e);
924
948
  end = appendText(end, "\n");
925
- write(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
949
+ write_nowarn(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
926
950
  }
927
951
  }
928
952
 
@@ -930,7 +954,7 @@ abortHandler(int signo, siginfo_t *info, void *ctx) {
930
954
  end = state.messageBuf;
931
955
  end = appendText(end, state.messagePrefix);
932
956
  end = appendText(end, " ] PASSENGER_STOP_ON_ABORT on, so process stopped. Send SIGCONT when you want to continue.\n");
933
- write(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
957
+ write_nowarn(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
934
958
  raise(SIGSTOP);
935
959
  }
936
960
 
@@ -970,7 +994,7 @@ abortHandler(int signo, siginfo_t *info, void *ctx) {
970
994
  end = appendText(end, "] Could fork a child process for dumping diagnostics: fork() failed with errno=");
971
995
  end = appendULL(end, e);
972
996
  end = appendText(end, "\n");
973
- write(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
997
+ write_nowarn(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
974
998
  _exit(1);
975
999
 
976
1000
  } else {
@@ -985,7 +1009,7 @@ abortHandler(int signo, siginfo_t *info, void *ctx) {
985
1009
  end = appendText(end, " ] Could fork a child process for dumping diagnostics: fork() failed with errno=");
986
1010
  end = appendULL(end, e);
987
1011
  end = appendText(end, "\n");
988
- write(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
1012
+ write_nowarn(STDERR_FILENO, state.messageBuf, end - state.messageBuf);
989
1013
 
990
1014
  } else {
991
1015
  raise(SIGSTOP);
@@ -1477,8 +1501,8 @@ initializeAgent(int argc, char *argv[], const char *processName) {
1477
1501
  shouldDumpWithCrashWatch = hasEnvOption("PASSENGER_DUMP_WITH_CRASH_WATCH", true);
1478
1502
  beepOnAbort = hasEnvOption("PASSENGER_BEEP_ON_ABORT", false);
1479
1503
  stopOnAbort = hasEnvOption("PASSENGER_STOP_ON_ABORT", false);
1480
- pipe(emergencyPipe1);
1481
- pipe(emergencyPipe2);
1504
+ IGNORE_SYSCALL_RESULT(pipe(emergencyPipe1));
1505
+ IGNORE_SYSCALL_RESULT(pipe(emergencyPipe2));
1482
1506
  installAbortHandler();
1483
1507
  }
1484
1508
  oxt::initialize();