passenger 2.2.1 → 2.2.2

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 (216) hide show
  1. data/Rakefile +66 -79
  2. data/bin/passenger-install-nginx-module +1 -1
  3. data/bin/passenger-memory-stats +1 -1
  4. data/bin/passenger-spawn-server +8 -2
  5. data/doc/Users guide Apache.html +33 -49
  6. data/doc/Users guide Apache.txt +28 -27
  7. data/doc/Users guide Nginx.html +9 -19
  8. data/doc/Users guide Nginx.txt +8 -20
  9. data/doc/cxxapi/Bucket_8h-source.html +1 -1
  10. data/doc/cxxapi/Configuration_8h-source.html +297 -300
  11. data/doc/cxxapi/DirectoryMapper_8h-source.html +1 -1
  12. data/doc/cxxapi/Hooks_8h-source.html +1 -1
  13. data/doc/cxxapi/annotated.html +1 -1
  14. data/doc/cxxapi/classHooks-members.html +1 -1
  15. data/doc/cxxapi/classHooks.html +1 -1
  16. data/doc/cxxapi/classPassenger_1_1DirectoryMapper-members.html +1 -1
  17. data/doc/cxxapi/classPassenger_1_1DirectoryMapper.html +1 -1
  18. data/doc/cxxapi/classes.html +1 -1
  19. data/doc/cxxapi/definitions_8h-source.html +1 -1
  20. data/doc/cxxapi/files.html +1 -1
  21. data/doc/cxxapi/functions.html +1 -1
  22. data/doc/cxxapi/functions_func.html +1 -1
  23. data/doc/cxxapi/graph_legend.html +1 -1
  24. data/doc/cxxapi/group__Configuration.html +1 -23
  25. data/doc/cxxapi/group__Core.html +1 -1
  26. data/doc/cxxapi/group__Hooks.html +1 -1
  27. data/doc/cxxapi/group__Support.html +1 -1
  28. data/doc/cxxapi/main.html +1 -1
  29. data/doc/cxxapi/modules.html +1 -1
  30. data/doc/users_guide_snippets/rackup_specifications.txt +4 -2
  31. data/ext/apache2/Configuration.h +0 -3
  32. data/ext/apache2/Hooks.cpp +5 -3
  33. data/ext/common/ApplicationPoolServer.h +1 -0
  34. data/ext/common/ApplicationPoolServerExecutable.cpp +5 -2
  35. data/ext/common/SpawnManager.h +1 -0
  36. data/ext/common/Utils.cpp +22 -23
  37. data/ext/common/Utils.h +32 -21
  38. data/ext/common/Version.h +31 -0
  39. data/ext/nginx/ContentHandler.c +61 -8
  40. data/ext/nginx/HelperServer.cpp +3 -0
  41. data/ext/nginx/HttpStatusExtractor.h +185 -0
  42. data/ext/nginx/StaticContentHandler.c +18 -3
  43. data/ext/nginx/config +2 -1
  44. data/ext/nginx/ngx_http_passenger_module.c +21 -15
  45. data/ext/oxt/backtrace.cpp +4 -2
  46. data/ext/oxt/spin_lock.hpp +3 -3
  47. data/lib/phusion_passenger/abstract_request_handler.rb +5 -3
  48. data/lib/phusion_passenger/admin_tools/control_process.rb +6 -1
  49. data/lib/phusion_passenger/constants.rb +2 -2
  50. data/lib/phusion_passenger/rack/application_spawner.rb +2 -1
  51. data/lib/phusion_passenger/rack/request_handler.rb +45 -35
  52. data/lib/phusion_passenger/templates/nginx/config_snippets.txt.erb +1 -1
  53. data/lib/phusion_passenger/utils.rb +13 -3
  54. data/misc/rake/cplusplus.rb +7 -0
  55. data/test/ApplicationPoolServer_ApplicationPoolTest.cpp +2 -0
  56. data/test/ApplicationPoolTest.cpp +39 -62
  57. data/test/CxxTestMain.cpp +6 -6
  58. data/test/HttpStatusExtractorTest.cpp +17 -0
  59. data/test/StandardApplicationPoolTest.cpp +2 -0
  60. data/test/UtilsTest.cpp +17 -28
  61. data/test/ruby/abstract_request_handler_spec.rb +3 -7
  62. data/test/ruby/utils_spec.rb +18 -13
  63. data/test/ruby/wsgi/application_spawner_spec.rb +5 -9
  64. data/test/stub/railsapp/app/controllers/{bar_controller_1.rb → bar_controller.rb} +0 -0
  65. data/test/stub/railsapp/app/controllers/bar_controller_1.txt +5 -0
  66. data/test/stub/railsapp/app/controllers/{bar_controller_2.rb → bar_controller_2.txt} +0 -0
  67. data/test/support/Support.h +20 -0
  68. data/test/support/config.rb +13 -0
  69. data/vendor/README +4 -3
  70. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/COPYING +1 -1
  71. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/KNOWN-ISSUES +0 -0
  72. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/README +54 -7
  73. data/vendor/rack-1.0.0-git/Rakefile +164 -0
  74. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack.rb +7 -3
  75. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/adapter/camping.rb +0 -0
  76. data/vendor/rack-1.0.0-git/lib/rack/auth/abstract/handler.rb +37 -0
  77. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/auth/abstract/request.rb +0 -0
  78. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/auth/basic.rb +0 -0
  79. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/auth/digest/md5.rb +1 -1
  80. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/auth/digest/nonce.rb +0 -0
  81. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/auth/digest/params.rb +0 -0
  82. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/auth/digest/request.rb +2 -2
  83. data/vendor/rack-1.0.0-git/lib/rack/auth/openid.rb +480 -0
  84. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/builder.rb +1 -5
  85. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/cascade.rb +0 -0
  86. data/vendor/rack-1.0.0-git/lib/rack/chunked.rb +49 -0
  87. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/commonlogger.rb +0 -0
  88. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/conditionalget.rb +4 -0
  89. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/content_length.rb +7 -3
  90. data/vendor/rack-1.0.0-git/lib/rack/content_type.rb +23 -0
  91. data/vendor/rack-1.0.0-git/lib/rack/deflater.rb +96 -0
  92. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/directory.rb +5 -2
  93. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/file.rb +4 -1
  94. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/handler.rb +22 -1
  95. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/handler/cgi.rb +7 -3
  96. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/handler/evented_mongrel.rb +0 -0
  97. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/handler/fastcgi.rb +26 -24
  98. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/handler/lsws.rb +7 -4
  99. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/handler/mongrel.rb +5 -3
  100. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/handler/scgi.rb +5 -3
  101. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/handler/swiftiplied_mongrel.rb +0 -0
  102. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/handler/thin.rb +3 -0
  103. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/handler/webrick.rb +11 -5
  104. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/head.rb +0 -0
  105. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/lint.rb +138 -66
  106. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/lobster.rb +0 -0
  107. data/vendor/rack-1.0.0-git/lib/rack/lock.rb +16 -0
  108. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/methodoverride.rb +0 -0
  109. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/mime.rb +4 -4
  110. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/mock.rb +42 -5
  111. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/recursive.rb +0 -0
  112. data/vendor/rack-1.0.0-git/lib/rack/reloader.rb +106 -0
  113. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/request.rb +46 -10
  114. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/response.rb +15 -3
  115. data/vendor/rack-1.0.0-git/lib/rack/rewindable_input.rb +98 -0
  116. data/vendor/rack-1.0.0-git/lib/rack/session/abstract/id.rb +142 -0
  117. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/session/cookie.rb +2 -0
  118. data/vendor/rack-1.0.0-git/lib/rack/session/memcache.rb +109 -0
  119. data/vendor/rack-1.0.0-git/lib/rack/session/pool.rb +100 -0
  120. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/showexceptions.rb +2 -1
  121. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/showstatus.rb +1 -1
  122. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/static.rb +0 -0
  123. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/urlmap.rb +12 -5
  124. data/vendor/{rack-0.9.1 → rack-1.0.0-git}/lib/rack/utils.rb +212 -65
  125. metadata +71 -170
  126. data/doc/rdoc/classes/ConditionVariable.html +0 -194
  127. data/doc/rdoc/classes/Exception.html +0 -120
  128. data/doc/rdoc/classes/GC.html +0 -113
  129. data/doc/rdoc/classes/IO.html +0 -169
  130. data/doc/rdoc/classes/PhusionPassenger.html +0 -238
  131. data/doc/rdoc/classes/PhusionPassenger/AbstractInstaller.html +0 -153
  132. data/doc/rdoc/classes/PhusionPassenger/AbstractRequestHandler.html +0 -506
  133. data/doc/rdoc/classes/PhusionPassenger/AbstractServer.html +0 -692
  134. data/doc/rdoc/classes/PhusionPassenger/AbstractServer/ServerAlreadyStarted.html +0 -97
  135. data/doc/rdoc/classes/PhusionPassenger/AbstractServer/ServerError.html +0 -96
  136. data/doc/rdoc/classes/PhusionPassenger/AbstractServer/ServerNotStarted.html +0 -97
  137. data/doc/rdoc/classes/PhusionPassenger/AbstractServer/UnknownMessage.html +0 -96
  138. data/doc/rdoc/classes/PhusionPassenger/AbstractServerCollection.html +0 -598
  139. data/doc/rdoc/classes/PhusionPassenger/AdminTools.html +0 -140
  140. data/doc/rdoc/classes/PhusionPassenger/AdminTools/ControlProcess.html +0 -264
  141. data/doc/rdoc/classes/PhusionPassenger/AdminTools/ControlProcess/Instance.html +0 -138
  142. data/doc/rdoc/classes/PhusionPassenger/AppInitError.html +0 -154
  143. data/doc/rdoc/classes/PhusionPassenger/Application.html +0 -283
  144. data/doc/rdoc/classes/PhusionPassenger/ConsoleTextTemplate.html +0 -172
  145. data/doc/rdoc/classes/PhusionPassenger/FrameworkInitError.html +0 -145
  146. data/doc/rdoc/classes/PhusionPassenger/HTMLTemplate.html +0 -175
  147. data/doc/rdoc/classes/PhusionPassenger/InitializationError.html +0 -141
  148. data/doc/rdoc/classes/PhusionPassenger/InvalidPath.html +0 -92
  149. data/doc/rdoc/classes/PhusionPassenger/MessageChannel.html +0 -489
  150. data/doc/rdoc/classes/PhusionPassenger/NativeSupport.html +0 -350
  151. data/doc/rdoc/classes/PhusionPassenger/Rack.html +0 -91
  152. data/doc/rdoc/classes/PhusionPassenger/Rack/ApplicationSpawner.html +0 -185
  153. data/doc/rdoc/classes/PhusionPassenger/Rack/RequestHandler.html +0 -184
  154. data/doc/rdoc/classes/PhusionPassenger/Railz.html +0 -95
  155. data/doc/rdoc/classes/PhusionPassenger/Railz/ApplicationSpawner.html +0 -419
  156. data/doc/rdoc/classes/PhusionPassenger/Railz/ApplicationSpawner/Error.html +0 -98
  157. data/doc/rdoc/classes/PhusionPassenger/Railz/CGIFixed.html +0 -200
  158. data/doc/rdoc/classes/PhusionPassenger/Railz/FrameworkSpawner.html +0 -443
  159. data/doc/rdoc/classes/PhusionPassenger/Railz/FrameworkSpawner/Error.html +0 -98
  160. data/doc/rdoc/classes/PhusionPassenger/Railz/RequestHandler.html +0 -154
  161. data/doc/rdoc/classes/PhusionPassenger/SpawnManager.html +0 -402
  162. data/doc/rdoc/classes/PhusionPassenger/UnknownError.html +0 -125
  163. data/doc/rdoc/classes/PhusionPassenger/Utils.html +0 -694
  164. data/doc/rdoc/classes/PhusionPassenger/VersionNotFound.html +0 -140
  165. data/doc/rdoc/classes/PhusionPassenger/WSGI.html +0 -89
  166. data/doc/rdoc/classes/PhusionPassenger/WSGI/ApplicationSpawner.html +0 -188
  167. data/doc/rdoc/classes/PlatformInfo.html +0 -831
  168. data/doc/rdoc/classes/RakeExtensions.html +0 -197
  169. data/doc/rdoc/classes/Signal.html +0 -134
  170. data/doc/rdoc/created.rid +0 -1
  171. data/doc/rdoc/files/DEVELOPERS_TXT.html +0 -240
  172. data/doc/rdoc/files/README.html +0 -157
  173. data/doc/rdoc/files/ext/phusion_passenger/native_support_c.html +0 -92
  174. data/doc/rdoc/files/lib/phusion_passenger/abstract_installer_rb.html +0 -129
  175. data/doc/rdoc/files/lib/phusion_passenger/abstract_request_handler_rb.html +0 -131
  176. data/doc/rdoc/files/lib/phusion_passenger/abstract_server_collection_rb.html +0 -126
  177. data/doc/rdoc/files/lib/phusion_passenger/abstract_server_rb.html +0 -130
  178. data/doc/rdoc/files/lib/phusion_passenger/admin_tools/control_process_rb.html +0 -129
  179. data/doc/rdoc/files/lib/phusion_passenger/admin_tools_rb.html +0 -122
  180. data/doc/rdoc/files/lib/phusion_passenger/application_rb.html +0 -127
  181. data/doc/rdoc/files/lib/phusion_passenger/console_text_template_rb.html +0 -126
  182. data/doc/rdoc/files/lib/phusion_passenger/constants_rb.html +0 -122
  183. data/doc/rdoc/files/lib/phusion_passenger/dependencies_rb.html +0 -134
  184. data/doc/rdoc/files/lib/phusion_passenger/events_rb.html +0 -122
  185. data/doc/rdoc/files/lib/phusion_passenger/exceptions_rb.html +0 -122
  186. data/doc/rdoc/files/lib/phusion_passenger/html_template_rb.html +0 -126
  187. data/doc/rdoc/files/lib/phusion_passenger/message_channel_rb.html +0 -122
  188. data/doc/rdoc/files/lib/phusion_passenger/packaging_rb.html +0 -122
  189. data/doc/rdoc/files/lib/phusion_passenger/platform_info_rb.html +0 -127
  190. data/doc/rdoc/files/lib/phusion_passenger/rack/application_spawner_rb.html +0 -133
  191. data/doc/rdoc/files/lib/phusion_passenger/rack/request_handler_rb.html +0 -126
  192. data/doc/rdoc/files/lib/phusion_passenger/railz/application_spawner_rb.html +0 -143
  193. data/doc/rdoc/files/lib/phusion_passenger/railz/cgi_fixed_rb.html +0 -126
  194. data/doc/rdoc/files/lib/phusion_passenger/railz/framework_spawner_rb.html +0 -145
  195. data/doc/rdoc/files/lib/phusion_passenger/railz/request_handler_rb.html +0 -127
  196. data/doc/rdoc/files/lib/phusion_passenger/simple_benchmarking_rb.html +0 -122
  197. data/doc/rdoc/files/lib/phusion_passenger/spawn_manager_rb.html +0 -161
  198. data/doc/rdoc/files/lib/phusion_passenger/utils_rb.html +0 -175
  199. data/doc/rdoc/files/lib/phusion_passenger/wsgi/application_spawner_rb.html +0 -129
  200. data/doc/rdoc/files/misc/rake/extensions_rb.html +0 -130
  201. data/doc/rdoc/fr_class_index.html +0 -90
  202. data/doc/rdoc/fr_file_index.html +0 -76
  203. data/doc/rdoc/fr_method_index.html +0 -195
  204. data/doc/rdoc/index.html +0 -26
  205. data/doc/rdoc/rdoc-style.css +0 -187
  206. data/vendor/rack-0.9.1/AUTHORS +0 -8
  207. data/vendor/rack-0.9.1/ChangeLog +0 -1423
  208. data/vendor/rack-0.9.1/Rakefile +0 -188
  209. data/vendor/rack-0.9.1/SPEC +0 -129
  210. data/vendor/rack-0.9.1/lib/rack/auth/abstract/handler.rb +0 -28
  211. data/vendor/rack-0.9.1/lib/rack/auth/openid.rb +0 -438
  212. data/vendor/rack-0.9.1/lib/rack/deflater.rb +0 -87
  213. data/vendor/rack-0.9.1/lib/rack/reloader.rb +0 -64
  214. data/vendor/rack-0.9.1/lib/rack/session/abstract/id.rb +0 -153
  215. data/vendor/rack-0.9.1/lib/rack/session/memcache.rb +0 -97
  216. data/vendor/rack-0.9.1/lib/rack/session/pool.rb +0 -73
data/ext/nginx/config CHANGED
@@ -20,7 +20,8 @@ NGX_ADDON_DEPS="$NGX_ADDON_DEPS \
20
20
  ${ngx_addon_dir}/Configuration.h \
21
21
  ${ngx_addon_dir}/ContentHandler.h \
22
22
  ${ngx_addon_dir}/StaticContentHandler.h \
23
- ${ngx_addon_dir}/ngx_http_passenger_module.h"
23
+ ${ngx_addon_dir}/ngx_http_passenger_module.h \
24
+ ${ngx_addon_dir}/../common/Version.h"
24
25
  CORE_LIBS="$CORE_LIBS \
25
26
  ${ngx_addon_dir}/libpassenger_common.a \
26
27
  ${ngx_addon_dir}/libboost_oxt.a \
@@ -49,8 +49,9 @@
49
49
  #define HELPER_SERVER_PASSWORD_SIZE 64
50
50
 
51
51
 
52
+ static int first_start = 1;
52
53
  static ngx_str_t ngx_http_scgi_script_name = ngx_string("scgi_script_name");
53
- static pid_t helper_server_pid;
54
+ static pid_t helper_server_pid = 0;
54
55
  static int helper_server_admin_pipe;
55
56
  static u_char helper_server_password_data[HELPER_SERVER_PASSWORD_SIZE];
56
57
  const char passenger_temp_dir[NGX_MAX_PATH];
@@ -59,6 +60,8 @@ ngx_str_t passenger_helper_server_password;
59
60
  const char passenger_helper_server_socket[NGX_MAX_PATH];
60
61
  CachedMultiFileStat *passenger_stat_cache;
61
62
 
63
+ static void shutdown_helper_server(ngx_cycle_t *cycle);
64
+
62
65
 
63
66
  /*
64
67
  HISTORIC NOTE:
@@ -121,14 +124,21 @@ start_helper_server(ngx_cycle_t *cycle)
121
124
  char buf;
122
125
  FILE *f;
123
126
 
124
- ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
127
+ if (helper_server_pid != 0) {
128
+ shutdown_helper_server(cycle);
129
+ }
125
130
 
126
- /* Ignore SIGPIPE now so that, if the helper server fails to start,
127
- * nginx doesn't get killed by the default SIGPIPE handler upon
128
- * writing the password to the helper server.
129
- */
130
- ignore_sigpipe();
131
+ ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
131
132
 
133
+ if (first_start) {
134
+ first_start = 0;
135
+
136
+ /* Ignore SIGPIPE now so that, if the helper server fails to start,
137
+ * nginx doesn't get killed by the default SIGPIPE handler upon
138
+ * writing the password to the helper server.
139
+ */
140
+ ignore_sigpipe();
141
+ }
132
142
 
133
143
  /* Build strings that we need later. */
134
144
 
@@ -231,12 +241,6 @@ start_helper_server(ngx_cycle_t *cycle)
231
241
  close(i);
232
242
  }
233
243
 
234
- /* It seems that Nginx's Perl module unsets the
235
- * PASSENGER_INSTANCE_TEMP_DIR environment variable, so here
236
- * we set it again.
237
- */
238
- setenv("PASSENGER_INSTANCE_TEMP_DIR", passenger_temp_dir, 1);
239
-
240
244
  execlp((const char *) helper_server_filename,
241
245
  "PassengerNginxHelperServer",
242
246
  main_conf->root_dir.data,
@@ -251,6 +255,7 @@ start_helper_server(ngx_cycle_t *cycle)
251
255
  main_conf->default_user.data,
252
256
  worker_uid_string,
253
257
  worker_gid_string,
258
+ passenger_temp_dir,
254
259
  NULL);
255
260
  e = errno;
256
261
  fprintf(stderr, "*** Could not start the Passenger helper server (%s): "
@@ -407,7 +412,7 @@ shutdown_helper_server(ngx_cycle_t *cycle)
407
412
  ngx_log_debug0(NGX_LOG_DEBUG_HTTP, cycle->log, 0,
408
413
  "Passenger helper server did not exit in time. "
409
414
  "Killing it...");
410
- kill(helper_server_pid, SIGTERM);
415
+ kill(helper_server_pid, SIGKILL);
411
416
  waitpid(helper_server_pid, NULL, 0);
412
417
  }
413
418
 
@@ -437,6 +442,8 @@ shutdown_helper_server(ngx_cycle_t *cycle)
437
442
  passenger_temp_dir);
438
443
  }
439
444
  }
445
+
446
+ helper_server_pid = 0;
440
447
  }
441
448
 
442
449
  static ngx_int_t
@@ -531,7 +538,6 @@ pre_config_init(ngx_conf_t *cf)
531
538
  "could not create Passenger temp dir string");
532
539
  return NGX_ERROR;
533
540
  }
534
- setenv("PASSENGER_INSTANCE_TEMP_DIR", passenger_temp_dir, 1);
535
541
 
536
542
  /* Temporarily create this temp directory. It must exist before the configuration is loaded,
537
543
  * because during Configuration loading Nginx's upstream module will attempt to create
@@ -45,9 +45,11 @@ static initialize_backtrace_support_for_this_thread main_thread_initialization("
45
45
  * than 4.1.2 have bugs (http://gcc.gnu.org/ml/gcc-bugs/2006-09/msg02275.html).
46
46
  */
47
47
 
48
- #define GCC_VERSION (__GNUC__ * 10000 \
48
+ #ifndef OXT_GCC_VERSION
49
+ #define OXT_GCC_VERSION (__GNUC__ * 10000 \
49
50
  + __GNUC_MINOR__ * 100 \
50
51
  + __GNUC_PATCHLEVEL__)
52
+ #endif
51
53
 
52
54
  /*
53
55
  * FreeBSD 5 supports the __thread keyword, and everything works fine in
@@ -62,7 +64,7 @@ static initialize_backtrace_support_for_this_thread main_thread_initialization("
62
64
  *
63
65
  * MacOS X doesn't support __thread at all.
64
66
  */
65
- #if GCC_VERSION >= 40102 && !defined(__FreeBSD__) && \
67
+ #if OXT_GCC_VERSION >= 40102 && !defined(__FreeBSD__) && \
66
68
  !defined(__SOLARIS__) && !defined(__OpenBSD__) && !defined(__APPLE__)
67
69
  static __thread spin_lock *backtrace_lock = NULL;
68
70
  static __thread vector<trace_point *> *current_backtrace = NULL;
@@ -34,13 +34,13 @@
34
34
  #define OXT_NO_PTHREAD_SPINLOCKS
35
35
  #endif
36
36
 
37
- #ifndef GCC_VERSION
38
- #define GCC_VERSION (__GNUC__ * 10000 \
37
+ #ifndef OXT_GCC_VERSION
38
+ #define OXT_GCC_VERSION (__GNUC__ * 10000 \
39
39
  + __GNUC_MINOR__ * 100 \
40
40
  + __GNUC_PATCH_LEVEL__)
41
41
  #endif
42
42
 
43
- #if (GCC_VERSION > 40100 && defined(__i386__)) || defined(IN_DOXYGEN)
43
+ #if (OXT_GCC_VERSION > 40100 && defined(__i386__)) || defined(IN_DOXYGEN)
44
44
  // GCC 4.0 doesn't support __sync instructions while GCC 4.2
45
45
  // does. I'm not sure whether support for it started in 4.1 or
46
46
  // 4.2, so the above version check may have to be changed later.
@@ -208,6 +208,10 @@ class AbstractRequestHandler
208
208
  ensure
209
209
  # 'input' is the same as 'client' so we don't
210
210
  # need to close that.
211
+ # The 'close_write' here prevents forked child
212
+ # processes from unintentionally keeping the
213
+ # connection open.
214
+ client.close_write rescue nil
211
215
  client.close rescue nil
212
216
  end
213
217
  @processed_requests += 1
@@ -382,9 +386,7 @@ private
382
386
 
383
387
  # We monkeypatch the 'sync=' method to a no-op so that
384
388
  # sync mode can't be disabled.
385
- client.instance_eval do
386
- def client.sync=(value)
387
- end
389
+ def client.sync=(value)
388
390
  end
389
391
 
390
392
  # The real input stream is not seekable (calling _seek_
@@ -63,7 +63,12 @@ class ControlProcess
63
63
  def initialize(path)
64
64
  @path = path
65
65
  if File.exist?("#{path}/control_process.pid")
66
- @pid = File.read("#{path}/control_process.pid").strip.to_i
66
+ data = File.read("#{path}/control_process.pid").strip
67
+ if data.empty?
68
+ raise ArgumentError, "'#{path}' is not a valid control process directory."
69
+ else
70
+ @pid = data.to_i
71
+ end
67
72
  else
68
73
  path =~ /passenger.(\d+)\Z/
69
74
  @pid = $1.to_i
@@ -23,8 +23,8 @@
23
23
 
24
24
  module PhusionPassenger
25
25
  # Phusion Passenger version number.
26
- # Don't forget to edit Configuration.h too.
27
- VERSION_STRING = '2.2.1'
26
+ # Don't forget to edit ext/common/Version.h too.
27
+ VERSION_STRING = '2.2.2'
28
28
 
29
29
  DEFAULT_FRAMEWORK_SPAWNER_MAX_IDLE_TIME = 30 * 60
30
30
  DEFAULT_APP_SPAWNER_MAX_IDLE_TIME = 10 * 60
@@ -21,7 +21,8 @@
21
21
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
22
  # THE SOFTWARE.
23
23
 
24
- $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../../../vendor/rack-0.9.1/lib"))
24
+ rack_dir = File.expand_path(File.dirname(__FILE__) + "/../../../vendor/rack-1.0.0-git/lib")
25
+ $LOAD_PATH.unshift(rack_dir) if !$LOAD_PATH.include?(rack_dir)
25
26
  require 'rack'
26
27
 
27
28
  require 'socket'
@@ -21,7 +21,12 @@
21
21
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
22
  # THE SOFTWARE.
23
23
 
24
+ rack_dir = File.expand_path(File.dirname(__FILE__) + "/../../../vendor/rack-1.0.0-git/lib")
25
+ $LOAD_PATH.unshift(rack_dir) if !$LOAD_PATH.include?(rack_dir)
26
+ require 'rack/rewindable_input'
27
+
24
28
  require 'phusion_passenger/abstract_request_handler'
29
+
25
30
  module PhusionPassenger
26
31
  module Rack
27
32
 
@@ -29,7 +34,7 @@ module Rack
29
34
  class RequestHandler < AbstractRequestHandler
30
35
  # Constants which exist to relieve Ruby's garbage collector.
31
36
  RACK_VERSION = "rack.version" # :nodoc:
32
- RACK_VERSION_VALUE = [0, 1] # :nodoc:
37
+ RACK_VERSION_VALUE = [1, 0] # :nodoc:
33
38
  RACK_INPUT = "rack.input" # :nodoc:
34
39
  RACK_ERRORS = "rack.errors" # :nodoc:
35
40
  RACK_MULTITHREAD = "rack.multithread" # :nodoc:
@@ -38,12 +43,14 @@ class RequestHandler < AbstractRequestHandler
38
43
  RACK_URL_SCHEME = "rack.url_scheme" # :nodoc:
39
44
  SCRIPT_NAME = "SCRIPT_NAME" # :nodoc:
40
45
  PATH_INFO = "PATH_INFO" # :nodoc:
46
+ REQUEST_URI = "REQUEST_URI" # :nodoc:
47
+ QUESTION_MARK = "?" # :nodoc:
41
48
  HTTPS = "HTTPS" # :nodoc:
42
49
  HTTPS_DOWNCASE = "https" # :nodoc:
43
50
  HTTP = "http" # :nodoc:
44
51
  YES = "yes" # :nodoc:
45
52
  ON = "on" # :nodoc:
46
- ONE = "one" # :nodoc:
53
+ ONE = "1" # :nodoc:
47
54
  CRLF = "\r\n" # :nodoc:
48
55
 
49
56
  # +app+ is the Rack application object.
@@ -55,44 +62,47 @@ class RequestHandler < AbstractRequestHandler
55
62
  protected
56
63
  # Overrided method.
57
64
  def process_request(env, input, output)
58
- env[RACK_VERSION] = RACK_VERSION_VALUE
59
- env[RACK_INPUT] = input
60
- env[RACK_ERRORS] = STDERR
61
- env[RACK_MULTITHREAD] = false
62
- env[RACK_MULTIPROCESS] = true
63
- env[RACK_RUN_ONCE] = false
64
- env[SCRIPT_NAME] ||= ''
65
- if ENV.has_key?(PATH_INFO)
66
- env[PATH_INFO].sub!(/^#{Regexp.escape(env[SCRIPT_NAME])}/, "")
67
- end
68
- if env[HTTPS] == YES || env[HTTPS] == ON || env[HTTPS] == ONE
69
- env[RACK_URL_SCHEME] = HTTPS_DOWNCASE
70
- else
71
- env[RACK_URL_SCHEME] = HTTP
72
- end
73
-
74
- status, headers, body = @app.call(env)
65
+ rewindable_input = ::Rack::RewindableInput.new(input)
75
66
  begin
76
- output.write("Status: #{status}#{CRLF}")
77
- headers[X_POWERED_BY] = PASSENGER_HEADER
78
- headers.each_pair do |key, values|
79
- if values.is_a?(String)
80
- values = values.split("\n")
81
- end
82
- values.each do |value|
83
- output.write("#{key}: #{value}#{CRLF}")
84
- end
67
+ env[RACK_VERSION] = RACK_VERSION_VALUE
68
+ env[RACK_INPUT] = rewindable_input
69
+ env[RACK_ERRORS] = STDERR
70
+ env[RACK_MULTITHREAD] = false
71
+ env[RACK_MULTIPROCESS] = true
72
+ env[RACK_RUN_ONCE] = false
73
+ env[PATH_INFO] ||= env[REQUEST_URI].split(QUESTION_MARK, 2).first
74
+ env[PATH_INFO].sub!(/^#{Regexp.escape(env[SCRIPT_NAME])}/, "")
75
+ if env[HTTPS] == YES || env[HTTPS] == ON || env[HTTPS] == ONE
76
+ env[RACK_URL_SCHEME] = HTTPS_DOWNCASE
77
+ else
78
+ env[RACK_URL_SCHEME] = HTTP
85
79
  end
86
- output.write(CRLF)
87
- if body.is_a?(String)
88
- output.write(body)
89
- elsif body
90
- body.each do |s|
91
- output.write(s)
80
+
81
+ status, headers, body = @app.call(env)
82
+ begin
83
+ output.write("Status: #{status.to_i}#{CRLF}")
84
+ output.write("X-Powered-By: #{PASSENGER_HEADER}#{CRLF}")
85
+ headers.each do |key, values|
86
+ if values.is_a?(String)
87
+ values = values.split("\n")
88
+ end
89
+ values.each do |value|
90
+ output.write("#{key}: #{value}#{CRLF}")
91
+ end
92
+ end
93
+ output.write(CRLF)
94
+ if body.is_a?(String)
95
+ output.write(body)
96
+ elsif body
97
+ body.each do |s|
98
+ output.write(s)
99
+ end
92
100
  end
101
+ ensure
102
+ body.close if body.respond_to?(:close)
93
103
  end
94
104
  ensure
95
- body.close if body.respond_to?(:close)
105
+ rewindable_input.close
96
106
  end
97
107
  end
98
108
  end
@@ -1,6 +1,6 @@
1
1
  <banner>Nginx with Passenger support was successfully installed.</banner>
2
2
 
3
- Please edit your Nginx configuration file (probably <b><%= @config_file %></b>),
3
+ Please edit your Nginx configuration file<% if @config_file %> (probably <b><%= @config_file %></b>)<% end %>,
4
4
  and set the <b>passenger_root</b> and <b>passenger_ruby</b> configuration options in the
5
5
  <b>'http'</b> block, like this:
6
6
 
@@ -337,14 +337,20 @@ protected
337
337
  return options
338
338
  end
339
339
 
340
+ @@passenger_tmpdir = nil
341
+
342
+ def passenger_tmpdir(create = true)
343
+ PhusionPassenger::Utils.passenger_tmpdir(create)
344
+ end
345
+
340
346
  # Returns the directory in which to store Phusion Passenger-specific
341
347
  # temporary files. If +create+ is true, then this method creates the
342
348
  # directory if it doesn't exist.
343
- def passenger_tmpdir(create = true)
344
- dir = ENV['PASSENGER_INSTANCE_TEMP_DIR']
349
+ def self.passenger_tmpdir(create = true)
350
+ dir = @@passenger_tmpdir
345
351
  if dir.nil? || dir.empty?
346
352
  dir = "#{Dir.tmpdir}/passenger.#{Process.pid}"
347
- ENV['PASSENGER_INSTANCE_TEMP_DIR'] = dir
353
+ @@passenger_tmpdir = dir
348
354
  end
349
355
  if create && !File.exist?(dir)
350
356
  # This is a very minimal implementation of the function
@@ -357,6 +363,10 @@ protected
357
363
  end
358
364
  return dir
359
365
  end
366
+
367
+ def self.passenger_tmpdir=(dir)
368
+ @@passenger_tmpdir = dir
369
+ end
360
370
  end
361
371
 
362
372
  end # module PhusionPassenger
@@ -32,6 +32,13 @@ def compile_cxx(source, flags = CXXFLAGS)
32
32
  end
33
33
 
34
34
  def create_static_library(target, sources)
35
+ # On OS X, 'ar cru' will sometimes fail with an obscure error:
36
+ #
37
+ # ar: foo.a is a fat file (use libtool(1) or lipo(1) and ar(1) on it)
38
+ # ar: foo.a: Inappropriate file type or format
39
+ #
40
+ # So here we delete the ar file before creating it, which bypasses this problem.
41
+ sh "rm -rf #{target}"
35
42
  sh "ar cru #{target} #{sources}"
36
43
  sh "ranlib #{target}"
37
44
  end
@@ -1,9 +1,11 @@
1
1
  #include "tut.h"
2
+ #include "support/Support.h"
2
3
  #include <boost/thread.hpp>
3
4
  #include "ApplicationPoolServer.h"
4
5
 
5
6
  using namespace Passenger;
6
7
  using namespace boost;
8
+ using namespace Test;
7
9
 
8
10
  namespace tut {
9
11
  struct ApplicationPoolServer_ApplicationPoolTest {
@@ -12,20 +12,7 @@
12
12
  * This file is used as a template to test the different ApplicationPool implementations.
13
13
  * It is #included in StandardApplicationPoolTest.cpp and ApplicationServer_ApplicationPoolTest.cpp
14
14
  */
15
- #ifdef USE_TEMPLATE
16
-
17
- struct TempFile {
18
- const char *filename;
19
-
20
- TempFile(const char *filename) {
21
- this->filename = filename;
22
- }
23
-
24
- ~TempFile() {
25
- unlink(filename);
26
- }
27
- };
28
-
15
+ #ifdef USE_TEMPLATE
29
16
  static string createRequestHeaders(const char *uri = "/foo/new") {
30
17
  string headers;
31
18
  #define ADD_HEADER(name, value) \
@@ -325,29 +312,25 @@
325
312
 
326
313
  TEST_METHOD(15) {
327
314
  // Test whether restarting really results in code reload.
328
- system("cp -f stub/railsapp/app/controllers/bar_controller_1.rb "
315
+ DeleteFileEventually f1("stub/railsapp/app/controllers/bar_controller.rb");
316
+ DeleteFileEventually f2("stub/railsapp/tmp/restart.txt");
317
+
318
+ system("cp -f stub/railsapp/app/controllers/bar_controller_1.txt "
329
319
  "stub/railsapp/app/controllers/bar_controller.rb");
330
320
  Application::SessionPtr session = pool->get("stub/railsapp");
331
321
  session->sendHeaders(createRequestHeaders("/bar"));
332
322
  string result = readAll(session->getStream());
333
323
  ensure(result.find("bar 1!") != string::npos);
334
324
  session.reset();
335
-
336
- system("cp -f stub/railsapp/app/controllers/bar_controller_2.rb "
325
+
326
+ system("cp -f stub/railsapp/app/controllers/bar_controller_2.txt "
337
327
  "stub/railsapp/app/controllers/bar_controller.rb");
338
328
  system("touch stub/railsapp/tmp/restart.txt");
339
- try {
340
- session = pool->get("stub/railsapp");
341
- session->sendHeaders(createRequestHeaders("/bar"));
342
- result = readAll(session->getStream());
343
- ensure("App code has been reloaded", result.find("bar 2!") != string::npos);
344
- } catch (...) {
345
- unlink("stub/railsapp/app/controllers/bar_controller.rb");
346
- unlink("touch stub/railsapp/tmp/restart.txt");
347
- throw;
348
- }
349
- unlink("stub/railsapp/app/controllers/bar_controller.rb");
350
- unlink("touch stub/railsapp/tmp/restart.txt");
329
+
330
+ session = pool->get("stub/railsapp");
331
+ session->sendHeaders(createRequestHeaders("/bar"));
332
+ result = readAll(session->getStream());
333
+ ensure("App code has been reloaded", result.find("bar 2!") != string::npos);
351
334
  }
352
335
 
353
336
  TEST_METHOD(16) {
@@ -509,39 +492,33 @@
509
492
 
510
493
  TEST_METHOD(22) {
511
494
  // Test whether tmp/always_restart.txt really results in code reload.
512
- try {
513
- system("cp -f stub/railsapp/app/controllers/bar_controller_1.rb "
514
- "stub/railsapp/app/controllers/bar_controller.rb");
515
- Application::SessionPtr session = pool->get("stub/railsapp");
516
- session->sendHeaders(createRequestHeaders("/bar"));
517
- string result = readAll(session->getStream());
518
- ensure(result.find("bar 1!") != string::npos);
519
- session.reset();
495
+ DeleteFileEventually f1("stub/railsapp/app/controllers/bar_controller.rb");
496
+ DeleteFileEventually f2("stub/railsapp/tmp/always_restart.txt");
497
+
498
+ system("cp -f stub/railsapp/app/controllers/bar_controller_1.txt "
499
+ "stub/railsapp/app/controllers/bar_controller.rb");
500
+ Application::SessionPtr session = pool->get("stub/railsapp");
501
+ session->sendHeaders(createRequestHeaders("/bar"));
502
+ string result = readAll(session->getStream());
503
+ ensure(result.find("bar 1!") != string::npos);
504
+ session.reset();
520
505
 
521
- system("cp -f stub/railsapp/app/controllers/bar_controller_2.rb "
522
- "stub/railsapp/app/controllers/bar_controller.rb");
523
- system("touch stub/railsapp/tmp/always_restart.txt");
524
- session = pool->get("stub/railsapp");
525
- session->sendHeaders(createRequestHeaders("/bar"));
526
- result = readAll(session->getStream());
527
- ensure("App code has been reloaded (1)", result.find("bar 2!") != string::npos);
528
- session.reset();
506
+ system("cp -f stub/railsapp/app/controllers/bar_controller_2.txt "
507
+ "stub/railsapp/app/controllers/bar_controller.rb");
508
+ system("touch stub/railsapp/tmp/always_restart.txt");
509
+ session = pool->get("stub/railsapp");
510
+ session->sendHeaders(createRequestHeaders("/bar"));
511
+ result = readAll(session->getStream());
512
+ ensure("App code has been reloaded (1)", result.find("bar 2!") != string::npos);
513
+ session.reset();
529
514
 
530
- system("cp -f stub/railsapp/app/controllers/bar_controller_1.rb "
531
- "stub/railsapp/app/controllers/bar_controller.rb");
532
- session = pool->get("stub/railsapp");
533
- session->sendHeaders(createRequestHeaders("/bar"));
534
- result = readAll(session->getStream());
535
- ensure("App code has been reloaded (2)", result.find("bar 1!") != string::npos);
536
- session.reset();
537
-
538
- unlink("stub/railsapp/app/controllers/bar_controller.rb");
539
- unlink("stub/railsapp/tmp/always_restart.txt");
540
- } catch (...) {
541
- unlink("stub/railsapp/app/controllers/bar_controller.rb");
542
- unlink("stub/railsapp/tmp/always_restart.txt");
543
- throw;
544
- }
515
+ system("cp -f stub/railsapp/app/controllers/bar_controller_1.txt "
516
+ "stub/railsapp/app/controllers/bar_controller.rb");
517
+ session = pool->get("stub/railsapp");
518
+ session->sendHeaders(createRequestHeaders("/bar"));
519
+ result = readAll(session->getStream());
520
+ ensure("App code has been reloaded (2)", result.find("bar 1!") != string::npos);
521
+ session.reset();
545
522
  }
546
523
 
547
524
  TEST_METHOD(23) {
@@ -592,7 +569,7 @@
592
569
  session1.reset();
593
570
  session2.reset();
594
571
 
595
- TempFile tempfile("stub/rack/restart.txt");
572
+ DeleteFileEventually f("stub/rack/restart.txt");
596
573
  system("touch stub/rack/restart.txt");
597
574
 
598
575
  pool->get(options);
@@ -617,7 +594,7 @@
617
594
  session1.reset();
618
595
  session2.reset();
619
596
 
620
- TempFile tempfile("stub/rack/public/restart.txt");
597
+ DeleteFileEventually f("stub/rack/public/restart.txt");
621
598
  system("touch stub/rack/public/restart.txt");
622
599
 
623
600
  pool->get(options);