passenger 2.0.3 → 2.0.4

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 (275) hide show
  1. data/Rakefile +8 -5
  2. data/bin/passenger-install-apache2-module +6 -1
  3. data/doc/ApplicationPool algorithm.txt +23 -5
  4. data/doc/Architectural overview.html +778 -0
  5. data/doc/Security of user switching support.html +1 -1
  6. data/doc/Users guide.html +113 -31
  7. data/doc/Users guide.txt +104 -10
  8. data/doc/cxxapi/ApplicationPoolServer_8h-source.html +683 -0
  9. data/doc/cxxapi/ApplicationPool_8h-source.html +224 -0
  10. data/doc/cxxapi/Application_8h-source.html +448 -0
  11. data/doc/cxxapi/Bucket_8h-source.html +61 -0
  12. data/doc/cxxapi/Configuration_8h-source.html +195 -0
  13. data/doc/cxxapi/DummySpawnManager_8h-source.html +126 -0
  14. data/doc/cxxapi/Exceptions_8h-source.html +244 -0
  15. data/doc/cxxapi/Hooks_8h-source.html +63 -0
  16. data/doc/cxxapi/Logging_8h-source.html +136 -0
  17. data/doc/cxxapi/MessageChannel_8h-source.html +524 -0
  18. data/doc/cxxapi/SpawnManager_8h-source.html +593 -0
  19. data/doc/cxxapi/StandardApplicationPool_8h-source.html +732 -0
  20. data/doc/cxxapi/System_8h-source.html +251 -0
  21. data/doc/cxxapi/Utils_8h-source.html +283 -0
  22. data/doc/cxxapi/annotated.html +59 -0
  23. data/doc/cxxapi/classClient-members.html +35 -0
  24. data/doc/cxxapi/classClient.html +117 -0
  25. data/doc/cxxapi/classDirectoryMapper-members.html +38 -0
  26. data/doc/cxxapi/classDirectoryMapper.html +203 -0
  27. data/doc/cxxapi/classHooks-members.html +33 -0
  28. data/doc/cxxapi/classHooks.html +43 -0
  29. data/doc/cxxapi/classPassenger_1_1Application-members.html +38 -0
  30. data/doc/cxxapi/classPassenger_1_1Application.html +229 -0
  31. data/doc/cxxapi/classPassenger_1_1ApplicationPool-members.html +41 -0
  32. data/doc/cxxapi/classPassenger_1_1ApplicationPool.html +359 -0
  33. data/doc/cxxapi/classPassenger_1_1ApplicationPoolServer-members.html +36 -0
  34. data/doc/cxxapi/classPassenger_1_1ApplicationPoolServer.html +225 -0
  35. data/doc/cxxapi/classPassenger_1_1ApplicationPool__inherit__graph.map +1 -0
  36. data/doc/cxxapi/classPassenger_1_1ApplicationPool__inherit__graph.md5 +1 -0
  37. data/doc/cxxapi/classPassenger_1_1ApplicationPool__inherit__graph.png +0 -0
  38. data/doc/cxxapi/classPassenger_1_1Application_1_1Session-members.html +43 -0
  39. data/doc/cxxapi/classPassenger_1_1Application_1_1Session.html +329 -0
  40. data/doc/cxxapi/classPassenger_1_1BusyException-members.html +33 -0
  41. data/doc/cxxapi/classPassenger_1_1BusyException.html +47 -0
  42. data/doc/cxxapi/classPassenger_1_1ConfigurationException-members.html +33 -0
  43. data/doc/cxxapi/classPassenger_1_1ConfigurationException.html +44 -0
  44. data/doc/cxxapi/classPassenger_1_1DummySpawnManager-members.html +33 -0
  45. data/doc/cxxapi/classPassenger_1_1DummySpawnManager.html +51 -0
  46. data/doc/cxxapi/classPassenger_1_1FileNotFoundException-members.html +33 -0
  47. data/doc/cxxapi/classPassenger_1_1FileNotFoundException.html +51 -0
  48. data/doc/cxxapi/classPassenger_1_1FileNotFoundException__inherit__graph.map +1 -0
  49. data/doc/cxxapi/classPassenger_1_1FileNotFoundException__inherit__graph.md5 +1 -0
  50. data/doc/cxxapi/classPassenger_1_1FileNotFoundException__inherit__graph.png +0 -0
  51. data/doc/cxxapi/classPassenger_1_1FileSystemException-members.html +38 -0
  52. data/doc/cxxapi/classPassenger_1_1FileSystemException.html +61 -0
  53. data/doc/cxxapi/classPassenger_1_1FileSystemException__inherit__graph.map +1 -0
  54. data/doc/cxxapi/classPassenger_1_1FileSystemException__inherit__graph.md5 +1 -0
  55. data/doc/cxxapi/classPassenger_1_1FileSystemException__inherit__graph.png +0 -0
  56. data/doc/cxxapi/classPassenger_1_1IOException-members.html +33 -0
  57. data/doc/cxxapi/classPassenger_1_1IOException.html +54 -0
  58. data/doc/cxxapi/classPassenger_1_1IOException__inherit__graph.map +1 -0
  59. data/doc/cxxapi/classPassenger_1_1IOException__inherit__graph.md5 +1 -0
  60. data/doc/cxxapi/classPassenger_1_1IOException__inherit__graph.png +0 -0
  61. data/doc/cxxapi/classPassenger_1_1MessageChannel-members.html +47 -0
  62. data/doc/cxxapi/classPassenger_1_1MessageChannel.html +591 -0
  63. data/doc/cxxapi/classPassenger_1_1SpawnException-members.html +35 -0
  64. data/doc/cxxapi/classPassenger_1_1SpawnException.html +77 -0
  65. data/doc/cxxapi/classPassenger_1_1SpawnManager-members.html +37 -0
  66. data/doc/cxxapi/classPassenger_1_1SpawnManager.html +255 -0
  67. data/doc/cxxapi/classPassenger_1_1StandardApplicationPool-members.html +43 -0
  68. data/doc/cxxapi/classPassenger_1_1StandardApplicationPool.html +400 -0
  69. data/doc/cxxapi/classPassenger_1_1StandardApplicationPool__inherit__graph.map +1 -0
  70. data/doc/cxxapi/classPassenger_1_1StandardApplicationPool__inherit__graph.md5 +1 -0
  71. data/doc/cxxapi/classPassenger_1_1StandardApplicationPool__inherit__graph.png +0 -0
  72. data/doc/cxxapi/classPassenger_1_1SystemException-members.html +37 -0
  73. data/doc/cxxapi/classPassenger_1_1SystemException.html +154 -0
  74. data/doc/cxxapi/classPassenger_1_1SystemException__inherit__graph.map +1 -0
  75. data/doc/cxxapi/classPassenger_1_1SystemException__inherit__graph.md5 +1 -0
  76. data/doc/cxxapi/classPassenger_1_1SystemException__inherit__graph.png +0 -0
  77. data/doc/cxxapi/classPassenger_1_1TempFile-members.html +36 -0
  78. data/doc/cxxapi/classPassenger_1_1TempFile.html +128 -0
  79. data/doc/cxxapi/classPassenger_1_1Thread-members.html +35 -0
  80. data/doc/cxxapi/classPassenger_1_1Thread.html +100 -0
  81. data/doc/cxxapi/classboost_1_1this__thread_1_1disable__syscall__interruption-members.html +33 -0
  82. data/doc/cxxapi/classboost_1_1this__thread_1_1disable__syscall__interruption.html +46 -0
  83. data/doc/cxxapi/classboost_1_1this__thread_1_1enable__syscall__interruption-members.html +33 -0
  84. data/doc/cxxapi/classboost_1_1this__thread_1_1enable__syscall__interruption.html +44 -0
  85. data/doc/cxxapi/classboost_1_1this__thread_1_1restore__syscall__interruption-members.html +33 -0
  86. data/doc/cxxapi/classboost_1_1this__thread_1_1restore__syscall__interruption.html +44 -0
  87. data/doc/cxxapi/definitions_8h-source.html +28 -0
  88. data/doc/cxxapi/doxygen.css +433 -0
  89. data/doc/cxxapi/doxygen.png +0 -0
  90. data/doc/cxxapi/files.html +42 -0
  91. data/doc/cxxapi/ftv2blank.png +0 -0
  92. data/doc/cxxapi/ftv2doc.png +0 -0
  93. data/doc/cxxapi/ftv2folderclosed.png +0 -0
  94. data/doc/cxxapi/ftv2folderopen.png +0 -0
  95. data/doc/cxxapi/ftv2lastnode.png +0 -0
  96. data/doc/cxxapi/ftv2link.png +0 -0
  97. data/doc/cxxapi/ftv2mlastnode.png +0 -0
  98. data/doc/cxxapi/ftv2mnode.png +0 -0
  99. data/doc/cxxapi/ftv2node.png +0 -0
  100. data/doc/cxxapi/ftv2plastnode.png +0 -0
  101. data/doc/cxxapi/ftv2pnode.png +0 -0
  102. data/doc/cxxapi/ftv2vertline.png +0 -0
  103. data/doc/cxxapi/functions.html +215 -0
  104. data/doc/cxxapi/functions_func.html +210 -0
  105. data/doc/cxxapi/functions_type.html +46 -0
  106. data/doc/cxxapi/functions_vars.html +48 -0
  107. data/doc/cxxapi/graph_legend.dot +22 -0
  108. data/doc/cxxapi/graph_legend.html +87 -0
  109. data/doc/cxxapi/graph_legend.png +0 -0
  110. data/doc/cxxapi/group__Configuration.html +236 -0
  111. data/doc/cxxapi/group__Configuration.png +0 -0
  112. data/doc/cxxapi/group__Core.html +51 -0
  113. data/doc/cxxapi/group__Core.png +0 -0
  114. data/doc/cxxapi/group__Exceptions.html +43 -0
  115. data/doc/cxxapi/group__Hooks.html +46 -0
  116. data/doc/cxxapi/group__Hooks.png +0 -0
  117. data/doc/cxxapi/group__Support.html +406 -0
  118. data/doc/cxxapi/hierarchy.html +67 -0
  119. data/doc/cxxapi/index.html +11 -0
  120. data/doc/cxxapi/inherit__graph__0.map +1 -0
  121. data/doc/cxxapi/inherit__graph__0.md5 +1 -0
  122. data/doc/cxxapi/inherit__graph__0.png +0 -0
  123. data/doc/cxxapi/inherit__graph__1.map +1 -0
  124. data/doc/cxxapi/inherit__graph__1.md5 +1 -0
  125. data/doc/cxxapi/inherit__graph__1.png +0 -0
  126. data/doc/cxxapi/inherit__graph__10.map +1 -0
  127. data/doc/cxxapi/inherit__graph__10.md5 +1 -0
  128. data/doc/cxxapi/inherit__graph__10.png +0 -0
  129. data/doc/cxxapi/inherit__graph__11.map +1 -0
  130. data/doc/cxxapi/inherit__graph__11.md5 +1 -0
  131. data/doc/cxxapi/inherit__graph__11.png +0 -0
  132. data/doc/cxxapi/inherit__graph__12.map +1 -0
  133. data/doc/cxxapi/inherit__graph__12.md5 +1 -0
  134. data/doc/cxxapi/inherit__graph__12.png +0 -0
  135. data/doc/cxxapi/inherit__graph__13.map +1 -0
  136. data/doc/cxxapi/inherit__graph__13.md5 +1 -0
  137. data/doc/cxxapi/inherit__graph__13.png +0 -0
  138. data/doc/cxxapi/inherit__graph__14.map +2 -0
  139. data/doc/cxxapi/inherit__graph__14.md5 +1 -0
  140. data/doc/cxxapi/inherit__graph__14.png +0 -0
  141. data/doc/cxxapi/inherit__graph__15.map +1 -0
  142. data/doc/cxxapi/inherit__graph__15.md5 +1 -0
  143. data/doc/cxxapi/inherit__graph__15.png +0 -0
  144. data/doc/cxxapi/inherit__graph__16.map +1 -0
  145. data/doc/cxxapi/inherit__graph__16.md5 +1 -0
  146. data/doc/cxxapi/inherit__graph__16.png +0 -0
  147. data/doc/cxxapi/inherit__graph__17.map +1 -0
  148. data/doc/cxxapi/inherit__graph__17.md5 +1 -0
  149. data/doc/cxxapi/inherit__graph__17.png +0 -0
  150. data/doc/cxxapi/inherit__graph__18.map +1 -0
  151. data/doc/cxxapi/inherit__graph__18.md5 +1 -0
  152. data/doc/cxxapi/inherit__graph__18.png +0 -0
  153. data/doc/cxxapi/inherit__graph__19.map +2 -0
  154. data/doc/cxxapi/inherit__graph__19.md5 +1 -0
  155. data/doc/cxxapi/inherit__graph__19.png +0 -0
  156. data/doc/cxxapi/inherit__graph__2.map +1 -0
  157. data/doc/cxxapi/inherit__graph__2.md5 +1 -0
  158. data/doc/cxxapi/inherit__graph__2.png +0 -0
  159. data/doc/cxxapi/inherit__graph__20.map +1 -0
  160. data/doc/cxxapi/inherit__graph__20.md5 +1 -0
  161. data/doc/cxxapi/inherit__graph__20.png +0 -0
  162. data/doc/cxxapi/inherit__graph__21.map +1 -0
  163. data/doc/cxxapi/inherit__graph__21.md5 +1 -0
  164. data/doc/cxxapi/inherit__graph__21.png +0 -0
  165. data/doc/cxxapi/inherit__graph__3.map +1 -0
  166. data/doc/cxxapi/inherit__graph__3.md5 +1 -0
  167. data/doc/cxxapi/inherit__graph__3.png +0 -0
  168. data/doc/cxxapi/inherit__graph__4.map +1 -0
  169. data/doc/cxxapi/inherit__graph__4.md5 +1 -0
  170. data/doc/cxxapi/inherit__graph__4.png +0 -0
  171. data/doc/cxxapi/inherit__graph__5.map +1 -0
  172. data/doc/cxxapi/inherit__graph__5.md5 +1 -0
  173. data/doc/cxxapi/inherit__graph__5.png +0 -0
  174. data/doc/cxxapi/inherit__graph__6.map +1 -0
  175. data/doc/cxxapi/inherit__graph__6.md5 +1 -0
  176. data/doc/cxxapi/inherit__graph__6.png +0 -0
  177. data/doc/cxxapi/inherit__graph__7.map +1 -0
  178. data/doc/cxxapi/inherit__graph__7.md5 +1 -0
  179. data/doc/cxxapi/inherit__graph__7.png +0 -0
  180. data/doc/cxxapi/inherit__graph__8.map +1 -0
  181. data/doc/cxxapi/inherit__graph__8.md5 +1 -0
  182. data/doc/cxxapi/inherit__graph__8.png +0 -0
  183. data/doc/cxxapi/inherit__graph__9.map +2 -0
  184. data/doc/cxxapi/inherit__graph__9.md5 +1 -0
  185. data/doc/cxxapi/inherit__graph__9.png +0 -0
  186. data/doc/cxxapi/inherits.html +102 -0
  187. data/doc/cxxapi/main.html +27 -0
  188. data/doc/cxxapi/modules.html +34 -0
  189. data/doc/cxxapi/namespacePassenger.html +208 -0
  190. data/doc/cxxapi/namespacePassenger_1_1InterruptableCalls.html +43 -0
  191. data/doc/cxxapi/namespacemembers.html +70 -0
  192. data/doc/cxxapi/namespacemembers_func.html +66 -0
  193. data/doc/cxxapi/namespacemembers_type.html +46 -0
  194. data/doc/cxxapi/namespaces.html +35 -0
  195. data/doc/cxxapi/structPassenger_1_1AnythingToString-members.html +33 -0
  196. data/doc/cxxapi/structPassenger_1_1AnythingToString.html +49 -0
  197. data/doc/cxxapi/structPassenger_1_1AnythingToString_3_01vector_3_01string_01_4_01_4-members.html +33 -0
  198. data/doc/cxxapi/structPassenger_1_1AnythingToString_3_01vector_3_01string_01_4_01_4.html +49 -0
  199. data/doc/cxxapi/tab_b.gif +0 -0
  200. data/doc/cxxapi/tab_l.gif +0 -0
  201. data/doc/cxxapi/tab_r.gif +0 -0
  202. data/doc/cxxapi/tabs.css +102 -0
  203. data/doc/cxxapi/tree.html +167 -0
  204. data/doc/rdoc/classes/ConditionVariable.html +160 -0
  205. data/doc/rdoc/classes/Exception.html +120 -0
  206. data/doc/rdoc/classes/GC.html +113 -0
  207. data/doc/rdoc/classes/IO.html +150 -0
  208. data/doc/rdoc/classes/Passenger.html +136 -0
  209. data/doc/rdoc/classes/Passenger/AbstractRequestHandler.html +402 -0
  210. data/doc/rdoc/classes/Passenger/AbstractServer.html +649 -0
  211. data/doc/rdoc/classes/Passenger/AbstractServer/ServerAlreadyStarted.html +97 -0
  212. data/doc/rdoc/classes/Passenger/AbstractServer/ServerError.html +96 -0
  213. data/doc/rdoc/classes/Passenger/AbstractServer/ServerNotStarted.html +97 -0
  214. data/doc/rdoc/classes/Passenger/AbstractServer/UnknownMessage.html +96 -0
  215. data/doc/rdoc/classes/Passenger/AppInitError.html +137 -0
  216. data/doc/rdoc/classes/Passenger/Application.html +298 -0
  217. data/doc/rdoc/classes/Passenger/ConsoleTextTemplate.html +172 -0
  218. data/doc/rdoc/classes/Passenger/FrameworkInitError.html +143 -0
  219. data/doc/rdoc/classes/Passenger/HTMLTemplate.html +175 -0
  220. data/doc/rdoc/classes/Passenger/InitializationError.html +141 -0
  221. data/doc/rdoc/classes/Passenger/MessageChannel.html +488 -0
  222. data/doc/rdoc/classes/Passenger/NativeSupport.html +320 -0
  223. data/doc/rdoc/classes/Passenger/SpawnManager.html +375 -0
  224. data/doc/rdoc/classes/Passenger/UnknownError.html +125 -0
  225. data/doc/rdoc/classes/Passenger/Utils.html +578 -0
  226. data/doc/rdoc/classes/Passenger/VersionNotFound.html +140 -0
  227. data/doc/rdoc/classes/PlatformInfo.html +302 -0
  228. data/doc/rdoc/classes/RakeExtensions.html +197 -0
  229. data/doc/rdoc/created.rid +1 -0
  230. data/doc/rdoc/files/DEVELOPERS_TXT.html +230 -0
  231. data/doc/rdoc/files/README.html +150 -0
  232. data/doc/rdoc/files/ext/passenger/native_support_c.html +92 -0
  233. data/doc/rdoc/files/lib/passenger/abstract_request_handler_rb.html +126 -0
  234. data/doc/rdoc/files/lib/passenger/abstract_server_rb.html +127 -0
  235. data/doc/rdoc/files/lib/passenger/application_rb.html +123 -0
  236. data/doc/rdoc/files/lib/passenger/console_text_template_rb.html +122 -0
  237. data/doc/rdoc/files/lib/passenger/constants_rb.html +114 -0
  238. data/doc/rdoc/files/lib/passenger/dependencies_rb.html +130 -0
  239. data/doc/rdoc/files/lib/passenger/exceptions_rb.html +118 -0
  240. data/doc/rdoc/files/lib/passenger/html_template_rb.html +122 -0
  241. data/doc/rdoc/files/lib/passenger/message_channel_rb.html +118 -0
  242. data/doc/rdoc/files/lib/passenger/platform_info_rb.html +122 -0
  243. data/doc/rdoc/files/lib/passenger/simple_benchmarking_rb.html +118 -0
  244. data/doc/rdoc/files/lib/passenger/spawn_manager_rb.html +139 -0
  245. data/doc/rdoc/files/lib/passenger/utils_rb.html +130 -0
  246. data/doc/rdoc/files/lib/rake/extensions_rb.html +122 -0
  247. data/doc/rdoc/fr_class_index.html +71 -0
  248. data/doc/rdoc/fr_file_index.html +63 -0
  249. data/doc/rdoc/fr_method_index.html +120 -0
  250. data/doc/rdoc/index.html +26 -0
  251. data/doc/rdoc/rdoc-style.css +187 -0
  252. data/ext/apache2/ApplicationPool.h +12 -0
  253. data/ext/apache2/ApplicationPoolServer.h +6 -0
  254. data/ext/apache2/ApplicationPoolServerExecutable.cpp +6 -0
  255. data/ext/apache2/Bucket.cpp +63 -69
  256. data/ext/apache2/Bucket.h +2 -0
  257. data/ext/apache2/Configuration.cpp +24 -0
  258. data/ext/apache2/Configuration.h +16 -1
  259. data/ext/apache2/Hooks.cpp +5 -3
  260. data/ext/apache2/StandardApplicationPool.h +30 -11
  261. data/lib/passenger/abstract_request_handler.rb +3 -0
  262. data/lib/passenger/abstract_server.rb +3 -3
  263. data/lib/passenger/application.rb +4 -2
  264. data/lib/passenger/dependencies.rb +10 -1
  265. data/lib/passenger/platform_info.rb +40 -1
  266. data/lib/passenger/rack/request_handler.rb +4 -2
  267. data/lib/passenger/railz/application_spawner.rb +7 -1
  268. data/lib/passenger/utils.rb +6 -8
  269. data/lib/rake/gempackagetask.rb +0 -6
  270. data/lib/rake/rdoctask.rb +84 -23
  271. data/test/ApplicationPoolTest.cpp +36 -0
  272. data/test/ruby/rails/minimal_spawner_spec.rb +8 -0
  273. data/test/ruby/utils_spec.rb +33 -0
  274. data/test/stub/rails_apps/foobar/config/environments/production.rb +0 -1
  275. metadata +262 -5
@@ -31,7 +31,7 @@
31
31
  */
32
32
 
33
33
  /** Module version number. */
34
- #define PASSENGER_VERSION "2.0.3"
34
+ #define PASSENGER_VERSION "2.0.4"
35
35
 
36
36
  #ifdef __cplusplus
37
37
  #include <set>
@@ -112,6 +112,13 @@
112
112
  * this server config. */
113
113
  bool poolIdleTimeSpecified;
114
114
 
115
+ /** Whether global queuing should be used. */
116
+ bool useGlobalQueue;
117
+
118
+ /** Whether the useGlobalQueue option was explicitly specified
119
+ * in this server config. */
120
+ bool useGlobalQueueSpecified;
121
+
115
122
  /** Whether user switching support is enabled. */
116
123
  bool userSwitching;
117
124
 
@@ -123,6 +130,14 @@
123
130
  * fails or is disabled. NULL means the option is not specified.
124
131
  */
125
132
  const char *defaultUser;
133
+
134
+ bool getUseGlobalQueue() const {
135
+ if (useGlobalQueueSpecified) {
136
+ return useGlobalQueue;
137
+ } else {
138
+ return false;
139
+ }
140
+ }
126
141
  };
127
142
  }
128
143
 
@@ -517,7 +517,7 @@ private:
517
517
  errno);
518
518
  }
519
519
  written += ret;
520
- } while (written < len);
520
+ } while (written < (size_t) len);
521
521
  }
522
522
  if (len == -1) {
523
523
  throw IOException("An error occurred while receiving HTTP upload data.");
@@ -614,6 +614,7 @@ public:
614
614
  applicationPool->setMax(config->maxPoolSize);
615
615
  applicationPool->setMaxPerApp(config->maxInstancesPerApp);
616
616
  applicationPool->setMaxIdleTime(config->poolIdleTime);
617
+ applicationPool->setUseGlobalQueue(config->getUseGlobalQueue());
617
618
  } catch (const thread_interrupted &) {
618
619
  P_TRACE(3, "A system call was interrupted during initialization of "
619
620
  "an Apache child process. Apache is probably restarting or "
@@ -700,10 +701,9 @@ public:
700
701
  P_TRACE(3, "Forwarding " << r->uri << " to PID " << session->getPid());
701
702
  } catch (const SpawnException &e) {
702
703
  if (e.hasErrorPage()) {
704
+ r->status = 500;
703
705
  ap_set_content_type(r, "text/html; charset=utf-8");
704
706
  ap_rputs(e.getErrorPage().c_str(), r);
705
- // Unfortunately we can't return a 500 Internal Server
706
- // Error. Apache's HTTP error handler would kick in.
707
707
  return OK;
708
708
  } else {
709
709
  throw;
@@ -860,6 +860,7 @@ destroy_hooks(void *arg) {
860
860
  this_thread::disable_syscall_interruption dsi;
861
861
  P_DEBUG("Shutting down Phusion Passenger...");
862
862
  delete hooks;
863
+ hooks = NULL;
863
864
  } catch (const thread_interrupted &) {
864
865
  // Ignore interruptions, we're shutting down anyway.
865
866
  P_TRACE(3, "A system call was interrupted during shutdown of mod_passenger.");
@@ -892,6 +893,7 @@ init_module(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *
892
893
  if (hooks != NULL) {
893
894
  P_DEBUG("Restarting Phusion Passenger....");
894
895
  delete hooks;
896
+ hooks = NULL;
895
897
  }
896
898
  try {
897
899
  hooks = new Hooks(pconf, plog, ptemp, s);
@@ -177,7 +177,9 @@ private:
177
177
  thread *cleanerThread;
178
178
  bool detached;
179
179
  bool done;
180
+ bool useGlobalQueue;
180
181
  unsigned int maxIdleTime;
182
+ unsigned int waitingOnGlobalQueue;
181
183
  condition cleanerThreadSleeper;
182
184
 
183
185
  // Shortcuts for instance variables in SharedData. Saves typing in get().
@@ -235,6 +237,8 @@ private:
235
237
  result << "count = " << count << endl;
236
238
  result << "active = " << active << endl;
237
239
  result << "inactive = " << inactiveApps.size() << endl;
240
+ result << "Using global queue: " << (useGlobalQueue ? "yes" : "no") << endl;
241
+ result << "Waiting on global queue: " << waitingOnGlobalQueue << endl;
238
242
  result << endl;
239
243
 
240
244
  result << "----------- Applications -----------" << endl;
@@ -360,6 +364,8 @@ private:
360
364
  const string &spawnMethod,
361
365
  const string &appType
362
366
  ) {
367
+ beginning_of_function:
368
+
363
369
  this_thread::disable_interruption di;
364
370
  this_thread::disable_syscall_interruption dsi;
365
371
  AppContainerPtr container;
@@ -404,19 +410,26 @@ private:
404
410
  } else if (count >= max || (
405
411
  maxPerApp != 0 && appInstanceCount[appRoot] >= maxPerApp )
406
412
  ) {
407
- AppContainerList::iterator it(list->begin());
408
- AppContainerList::iterator smallest(list->begin());
409
- it++;
410
- for (; it != list->end(); it++) {
411
- if ((*it)->sessions < (*smallest)->sessions) {
412
- smallest = it;
413
+ if (useGlobalQueue) {
414
+ waitingOnGlobalQueue++;
415
+ activeOrMaxChanged.wait(l);
416
+ waitingOnGlobalQueue--;
417
+ goto beginning_of_function;
418
+ } else {
419
+ AppContainerList::iterator it(list->begin());
420
+ AppContainerList::iterator smallest(list->begin());
421
+ it++;
422
+ for (; it != list->end(); it++) {
423
+ if ((*it)->sessions < (*smallest)->sessions) {
424
+ smallest = it;
425
+ }
413
426
  }
427
+ container = *smallest;
428
+ list->erase(smallest);
429
+ list->push_back(container);
430
+ container->iterator = list->end();
431
+ container->iterator--;
414
432
  }
415
- container = *smallest;
416
- list->erase(smallest);
417
- list->push_back(container);
418
- container->iterator = list->end();
419
- container->iterator--;
420
433
  } else {
421
434
  container = ptr(new AppContainer());
422
435
  {
@@ -547,6 +560,8 @@ public:
547
560
  max = DEFAULT_MAX_POOL_SIZE;
548
561
  count = 0;
549
562
  active = 0;
563
+ useGlobalQueue = false;
564
+ waitingOnGlobalQueue = 0;
550
565
  maxPerApp = DEFAULT_MAX_INSTANCES_PER_APP;
551
566
  maxIdleTime = DEFAULT_MAX_IDLE_TIME;
552
567
  cleanerThread = new thread(
@@ -667,6 +682,10 @@ public:
667
682
  activeOrMaxChanged.notify_all();
668
683
  }
669
684
 
685
+ virtual void setUseGlobalQueue(bool value) {
686
+ this->useGlobalQueue = value;
687
+ }
688
+
670
689
  virtual pid_t getSpawnServerPid() const {
671
690
  return spawnManager.getServerPid();
672
691
  }
@@ -17,6 +17,7 @@
17
17
  # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
18
 
19
19
  require 'socket'
20
+ require 'fcntl'
20
21
  require 'passenger/utils'
21
22
  require 'passenger/native_support'
22
23
  module Passenger
@@ -125,6 +126,7 @@ class AbstractRequestHandler
125
126
  if !@using_abstract_namespace
126
127
  create_unix_socket_on_filesystem
127
128
  end
129
+ @socket.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
128
130
  @owner_pipe = owner_pipe
129
131
  @previous_signal_handlers = {}
130
132
  end
@@ -258,6 +260,7 @@ private
258
260
  ios = select([@socket, @owner_pipe])[0]
259
261
  if ios.include?(@socket)
260
262
  client = @socket.accept
263
+ client.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
261
264
 
262
265
  # The real input stream is not seekable (calling _seek_
263
266
  # or _rewind_ on it will raise an exception). But some
@@ -119,12 +119,12 @@ class AbstractServer
119
119
  # on a white list of file descriptors. That proved to be way too fragile:
120
120
  # too many file descriptors are being left open even though they shouldn't
121
121
  # be. So now we close file descriptors based on a black list.
122
- file_descriptors_to_close = [0, 1, 2, @child_socket.fileno]
123
- NativeSupport.close_all_file_descriptors(file_descriptors_to_close)
122
+ file_descriptors_to_leave_open = [0, 1, 2, @child_socket.fileno]
123
+ NativeSupport.close_all_file_descriptors(file_descriptors_to_leave_open)
124
124
  # In addition to closing the file descriptors, one must also close
125
125
  # the associated IO objects. This is to prevent IO.close from
126
126
  # double-closing already closed file descriptors.
127
- close_all_io_objects_for_fds(Set.new(file_descriptors_to_close))
127
+ close_all_io_objects_for_fds(file_descriptors_to_leave_open)
128
128
 
129
129
  # At this point, RubyGems might have open file handles for which
130
130
  # the associated file descriptors have just been closed. This can
@@ -55,7 +55,8 @@ class Application
55
55
  return nil
56
56
  end
57
57
 
58
- found_version = Gem.cache.search('rails', gem_version_spec).map do |x|
58
+ search_results = Gem.cache.search(Gem::Dependency.new('rails', gem_version_spec), true)
59
+ found_version = search_results.map do |x|
59
60
  x.version.version
60
61
  end.sort.last
61
62
  if found_version.nil?
@@ -63,7 +64,8 @@ class Application
63
64
  # date because the Rails version may have been installed now.
64
65
  # So we reload the RubyGems cache and try again.
65
66
  Gem.clear_paths
66
- found_version = Gem.cache.search('rails', gem_version_spec).map do |x|
67
+ search_results = Gem.cache.search(Gem::Dependency.new('rails', gem_version_spec), true)
68
+ found_version = search_results.map do |x|
67
69
  x.version.version
68
70
  end.sort.last
69
71
  end
@@ -216,7 +216,7 @@ module Dependencies # :nodoc: all
216
216
  end
217
217
  elsif RUBY_PLATFORM =~ /freebsd/
218
218
  dep.install_command = "make -C /usr/ports/www/apache22 install"
219
- dep.provides = [Apache2_DevHeaders, APR_DevHeaders]
219
+ dep.provides = [Apache2_DevHeaders, APR_DevHeaders, APU_DevHeaders]
220
220
  end
221
221
  dep.website = "http://httpd.apache.org/"
222
222
  end
@@ -270,6 +270,15 @@ module Dependencies # :nodoc: all
270
270
  dep.website = "http://httpd.apache.org/"
271
271
  dep.website_comments = "APR is an integrated part of Apache."
272
272
  end
273
+
274
+ APU_DevHeaders = Dependency.new do |dep|
275
+ dep.name = "Apache Portable Runtime Utility (APR) development headers"
276
+ dep.define_checker do |result|
277
+ result.found(APU_CONFIG)
278
+ end
279
+ dep.website = "http://httpd.apache.org/"
280
+ dep.website_comments = "APR Utility is an integrated part of Apache."
281
+ end
273
282
 
274
283
  FastThread = Dependency.new do |dep|
275
284
  dep.name = "fastthread"
@@ -157,6 +157,42 @@ private
157
157
  return [flags, libs]
158
158
  end
159
159
  end
160
+
161
+ def self.find_apu_config
162
+ if env_defined?('APU_CONFIG')
163
+ apu_config = ENV['APU_CONFIG']
164
+ elsif RUBY_PLATFORM =~ /darwin/ && HTTPD == "/usr/sbin/httpd"
165
+ # If we're on MacOS X, and we're compiling against the
166
+ # default provided Apache, then we'll want to query the
167
+ # correct 'apu-1-config' command. However, that command
168
+ # is not in $PATH by default. Instead, it lives in
169
+ # /Developer/SDKs/MacOSX*sdk/usr/bin.
170
+ sdk_dir = Dir["/Developer/SDKs/MacOSX*sdk"].sort.last
171
+ if sdk_dir
172
+ apu_config = "#{sdk_dir}/usr/bin/apu-1-config"
173
+ if !File.executable?(apu_config)
174
+ apu_config = nil
175
+ end
176
+ end
177
+ else
178
+ apu_config = find_command('apu-1-config')
179
+ if apu_config.nil?
180
+ apu_config = find_command('apu-config')
181
+ end
182
+ end
183
+ return apu_config
184
+ end
185
+
186
+ def self.determine_apu_info
187
+ if APU_CONFIG.nil?
188
+ return nil
189
+ else
190
+ flags = `#{APU_CONFIG} --includes`.strip
191
+ libs = `#{APU_CONFIG} --link-ld`.strip
192
+ flags.gsub!(/-O\d? /, '')
193
+ return [flags, libs]
194
+ end
195
+ end
160
196
 
161
197
  def self.determine_multi_arch_flags
162
198
  if RUBY_PLATFORM =~ /darwin/ && !HTTPD.nil?
@@ -248,12 +284,15 @@ public
248
284
  HTTPD = find_httpd
249
285
  # The absolute path to the 'apr-config' or 'apr-1-config' executable.
250
286
  APR_CONFIG = find_apr_config
287
+ APU_CONFIG = find_apu_config
251
288
 
252
289
  # The C compiler flags that are necessary to compile an Apache module.
253
290
  APXS2_FLAGS = determine_apxs2_flags
254
291
  # The C compiler flags that are necessary for programs that use APR.
255
292
  APR_FLAGS, APR_LIBS = determine_apr_info
256
-
293
+ # The C compiler flags that are necessary for programs that use APR-Util.
294
+ APU_FLAGS, APU_LIBS = determine_apu_info
295
+
257
296
  # The C compiler flags that are necessary for building binaries in the same architecture(s) as Apache.
258
297
  MULTI_ARCH_FLAGS = determine_multi_arch_flags
259
298
  # The current platform's shared library extension ('so' on most Unices).
@@ -72,8 +72,10 @@ protected
72
72
  end
73
73
  end
74
74
  output.write(CRLF)
75
- body.each do |s|
76
- output.write(s)
75
+ if body
76
+ body.each do |s|
77
+ output.write(s)
78
+ end
77
79
  end
78
80
  ensure
79
81
  body.close if body.respond_to?(:close)
@@ -19,6 +19,7 @@
19
19
  require 'rubygems'
20
20
  require 'socket'
21
21
  require 'etc'
22
+ require 'fcntl'
22
23
  require 'passenger/application'
23
24
  require 'passenger/abstract_server'
24
25
  require 'passenger/application'
@@ -260,7 +261,11 @@ private
260
261
  if !defined?(Dispatcher)
261
262
  require 'dispatcher'
262
263
  end
263
- require_dependency 'application'
264
+ if File.exist?('app/controllers/application_controller.rb')
265
+ require_dependency 'application_controller'
266
+ else
267
+ require_dependency 'application'
268
+ end
264
269
  if GC.copy_on_write_friendly?
265
270
  Dir.glob('app/{models,controllers,helpers}/*.rb').each do |file|
266
271
  require_dependency normalize_path(file)
@@ -298,6 +303,7 @@ private
298
303
  ::ActiveRecord::Base.establish_connection
299
304
  end
300
305
 
306
+ reader.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
301
307
  handler = RequestHandler.new(reader)
302
308
  channel.write(Process.pid, handler.socket_name,
303
309
  handler.using_abstract_namespace?)
@@ -81,15 +81,13 @@ protected
81
81
  groupname && Etc.getgrnam(groupname)
82
82
  end
83
83
 
84
- def close_all_io_objects_for_fds(file_descriptors_to_close)
85
- ObjectSpace.each_object do |o|
86
- if o.is_a?(IO)
87
- begin
88
- if o.closed? && file_descriptors_to_close.include?(o.fileno)
89
- o.close
90
- end
91
- rescue
84
+ def close_all_io_objects_for_fds(file_descriptors_to_leave_open)
85
+ ObjectSpace.each_object(IO) do |io|
86
+ begin
87
+ if !file_descriptors_to_leave_open.include?(io.fileno) && !io.closed?
88
+ io.close
92
89
  end
90
+ rescue
93
91
  end
94
92
  end
95
93
  end
@@ -11,12 +11,6 @@ require 'rake/packagetask'
11
11
  require 'rubygems/user_interaction'
12
12
  require 'rubygems/builder'
13
13
 
14
- begin
15
- Gem.manage_gems
16
- rescue NoMethodError => ex
17
- # Using rubygems prior to 0.6.1
18
- end
19
-
20
14
  module Rake
21
15
 
22
16
  # Create a package based upon a Gem spec. Gem packages, as well as
@@ -1,6 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- # Passenger note: this file is copied from Rake 0.8.1. The task names
3
- # have been changed.
4
2
 
5
3
  require 'rake'
6
4
  require 'rake/tasklib'
@@ -12,7 +10,7 @@ module Rake
12
10
  #
13
11
  # The RDocTask will create the following targets:
14
12
  #
15
- # [<b><em>rdoc</em></b>]
13
+ # [<b>:<em>rdoc</em></b>]
16
14
  # Main task for this RDOC task.
17
15
  #
18
16
  # [<b>:clobber_<em>rdoc</em></b>]
@@ -23,13 +21,18 @@ module Rake
23
21
  # Rebuild the rdoc files from scratch, even if they are not out
24
22
  # of date.
25
23
  #
26
- # Simple Example:
24
+ # Simple example:
27
25
  #
28
26
  # Rake::RDocTask.new do |rd|
29
27
  # rd.main = "README.rdoc"
30
28
  # rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
31
29
  # end
32
30
  #
31
+ # The +rd+ object passed to the block is an RDocTask object. See the
32
+ # attributes list for the RDocTask class for available customization options.
33
+ #
34
+ # == Specifying different task names
35
+ #
33
36
  # You may wish to give the task a different name, such as if you are
34
37
  # generating two sets of documentation. For instance, if you want to have a
35
38
  # development set of documentation including private methods:
@@ -41,7 +44,17 @@ module Rake
41
44
  # end
42
45
  #
43
46
  # The tasks would then be named :<em>rdoc_dev</em>, :clobber_<em>rdoc_dev</em>, and
44
- # :re<em>rdoc_dev</em>.
47
+ # :re<em>rdoc_dev</em>.
48
+ #
49
+ # If you wish to have completely different task names, then pass a Hash as
50
+ # first argument. With the <tt>:rdoc</tt>, <tt>:clobber_rdoc</tt> and
51
+ # <tt>:rerdoc</tt> options, you can customize the task names to your liking.
52
+ # For example:
53
+ #
54
+ # Rake::RDocTask.new(:rdoc => "rdoc", :clobber_rdoc => "rdoc:clean", :rerdoc => "rdoc:force")
55
+ #
56
+ # This will create the tasks <tt>:rdoc</tt>, <tt>:rdoc_clean</tt> and
57
+ # <tt>:rdoc:force</tt>.
45
58
  #
46
59
  class RDocTask < TaskLib
47
60
  # Name of the main, top level task. (default is :rdoc)
@@ -50,34 +63,45 @@ module Rake
50
63
  # Name of directory to receive the html output files. (default is "html")
51
64
  attr_accessor :rdoc_dir
52
65
 
53
- # Title of RDoc documentation. (default is none)
66
+ # Title of RDoc documentation. (defaults to rdoc's default)
54
67
  attr_accessor :title
55
68
 
56
69
  # Name of file to be used as the main, top level file of the
57
70
  # RDoc. (default is none)
58
71
  attr_accessor :main
59
72
 
60
- # Name of template to be used by rdoc. (default is 'html')
73
+ # Name of template to be used by rdoc. (defaults to rdoc's default)
61
74
  attr_accessor :template
62
75
 
63
76
  # List of files to be included in the rdoc generation. (default is [])
64
77
  attr_accessor :rdoc_files
65
78
 
66
- # List of options to be passed rdoc. (default is [])
79
+ # Additional list of options to be passed rdoc. (default is [])
67
80
  attr_accessor :options
68
81
 
69
- # Run the rdoc process as an external shell (default is false)
82
+ # Whether to run the rdoc process as an external shell (default is false)
70
83
  attr_accessor :external
71
-
72
- # Create an RDoc task named <em>rdoc</em>. Default task name is +rdoc+.
73
- def initialize(name=:rdoc) # :yield: self
84
+
85
+ attr_accessor :inline_source
86
+
87
+ # Create an RDoc task with the given name. See the RDocTask class overview
88
+ # for documentation.
89
+ def initialize(name = :rdoc) # :yield: self
90
+ if name.is_a?(Hash)
91
+ invalid_options = name.keys.map { |k| k.to_sym } - [:rdoc, :clobber_rdoc, :rerdoc]
92
+ if !invalid_options.empty?
93
+ raise ArgumentError, "Invalid option(s) passed to RDocTask.new: #{invalid_options.join(", ")}"
94
+ end
95
+ end
96
+
74
97
  @name = name
75
98
  @rdoc_files = Rake::FileList.new
76
99
  @rdoc_dir = 'html'
77
100
  @main = nil
78
101
  @title = nil
79
- @template = 'html'
102
+ @template = nil
80
103
  @external = false
104
+ @inline_source = true
81
105
  @options = []
82
106
  yield self if block_given?
83
107
  define
@@ -85,26 +109,28 @@ module Rake
85
109
 
86
110
  # Create the tasks defined by this task lib.
87
111
  def define
88
- if name.to_s != "rdoc"
112
+ if rdoc_task_name != "rdoc"
89
113
  desc "Build the RDOC HTML Files"
114
+ else
115
+ desc "Build the #{rdoc_task_name} HTML Files"
90
116
  end
91
-
92
- desc "Build the #{name} HTML Files"
93
- task name
117
+ task rdoc_task_name
94
118
 
95
119
  desc "Force a rebuild of the RDOC files"
96
- task paste(name, ":force") => [paste(name, ":clobber"), name]
120
+ task rerdoc_task_name => [clobber_task_name, rdoc_task_name]
97
121
 
98
122
  desc "Remove rdoc products"
99
- task paste(name, ":clobber") do
123
+ task clobber_task_name do
100
124
  rm_r rdoc_dir rescue nil
101
125
  end
102
- task :clobber => [paste(name, ":clobber")]
126
+
127
+ task :clobber => [clobber_task_name]
103
128
 
104
129
  directory @rdoc_dir
105
- task name => [rdoc_target]
106
- file rdoc_target => @rdoc_files + [$rakefile] do
130
+ task rdoc_task_name => [rdoc_target]
131
+ file rdoc_target => @rdoc_files + [Rake.application.rakefile] do
107
132
  rm_r @rdoc_dir rescue nil
133
+ @before_running_rdoc.call if @before_running_rdoc
108
134
  args = option_list + @rdoc_files
109
135
  if @external
110
136
  argstring = args.join(' ')
@@ -123,6 +149,7 @@ module Rake
123
149
  result << "--main" << quote(main) if main
124
150
  result << "--title" << quote(title) if title
125
151
  result << "-T" << quote(template) if template
152
+ result << "--inline-source" if inline_source && !@options.include?("--inline-source") && !@options.include?("-S")
126
153
  result
127
154
  end
128
155
 
@@ -137,12 +164,46 @@ module Rake
137
164
  def option_string
138
165
  option_list.join(' ')
139
166
  end
167
+
168
+ # The block passed to this method will be called just before running the
169
+ # RDoc generator. It is allowed to modify RDocTask attributes inside the
170
+ # block.
171
+ def before_running_rdoc(&block)
172
+ @before_running_rdoc = block
173
+ end
140
174
 
141
175
  private
142
-
176
+
143
177
  def rdoc_target
144
178
  "#{rdoc_dir}/index.html"
145
179
  end
180
+
181
+ def rdoc_task_name
182
+ case name
183
+ when Hash
184
+ (name[:rdoc] || "rdoc").to_s
185
+ else
186
+ name.to_s
187
+ end
188
+ end
189
+
190
+ def clobber_task_name
191
+ case name
192
+ when Hash
193
+ (name[:clobber_rdoc] || "clobber_rdoc").to_s
194
+ else
195
+ "clobber_#{name}"
196
+ end
197
+ end
198
+
199
+ def rerdoc_task_name
200
+ case name
201
+ when Hash
202
+ (name[:rerdoc] || "rerdoc").to_s
203
+ else
204
+ "re#{name}"
205
+ end
206
+ end
146
207
 
147
208
  end
148
209
  end