passenger 1.0.1 → 1.0.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.
- data/LICENSE +3 -1
- data/Rakefile +17 -12
- data/bin/passenger-config +22 -0
- data/bin/passenger-install-apache2-module +2 -31
- data/bin/passenger-make-enterprisey +66 -0
- data/bin/passenger-memory-stats +192 -0
- data/doc/Users guide.html +150 -66
- data/doc/Users guide.txt +141 -51
- data/doc/cxxapi/ApplicationPoolClientServer_8h-source.html +1 -1
- data/doc/cxxapi/ApplicationPoolServer_8h-source.html +545 -0
- data/doc/cxxapi/ApplicationPool_8h-source.html +1 -1
- data/doc/cxxapi/Application_8h-source.html +1 -1
- data/doc/cxxapi/Configuration_8h-source.html +2 -2
- data/doc/cxxapi/DummySpawnManager_8h-source.html +1 -1
- data/doc/cxxapi/Exceptions_8h-source.html +1 -1
- data/doc/cxxapi/Hooks_8h-source.html +1 -1
- data/doc/cxxapi/Logging_8h-source.html +1 -1
- data/doc/cxxapi/MessageChannel_8h-source.html +210 -205
- data/doc/cxxapi/SpawnManager_8h-source.html +1 -1
- data/doc/cxxapi/StandardApplicationPool_8h-source.html +1 -1
- data/doc/cxxapi/Utils_8h-source.html +1 -1
- data/doc/cxxapi/annotated.html +1 -1
- data/doc/cxxapi/classClient-members.html +30 -0
- data/doc/cxxapi/classClient.html +112 -0
- data/doc/cxxapi/classPassenger_1_1Application-members.html +1 -1
- data/doc/cxxapi/classPassenger_1_1Application.html +1 -1
- data/doc/cxxapi/classPassenger_1_1ApplicationPool-members.html +1 -1
- data/doc/cxxapi/classPassenger_1_1ApplicationPool.html +1 -1
- data/doc/cxxapi/classPassenger_1_1ApplicationPoolServer-members.html +1 -1
- data/doc/cxxapi/classPassenger_1_1ApplicationPoolServer.html +1 -1
- data/doc/cxxapi/classPassenger_1_1Application_1_1Session-members.html +1 -1
- data/doc/cxxapi/classPassenger_1_1Application_1_1Session.html +1 -1
- data/doc/cxxapi/classPassenger_1_1ConfigurationException-members.html +28 -0
- data/doc/cxxapi/classPassenger_1_1ConfigurationException.html +41 -0
- data/doc/cxxapi/classPassenger_1_1DummySpawnManager-members.html +1 -1
- data/doc/cxxapi/classPassenger_1_1DummySpawnManager.html +1 -1
- data/doc/cxxapi/classPassenger_1_1FileNotFoundException-members.html +1 -1
- data/doc/cxxapi/classPassenger_1_1FileNotFoundException.html +1 -1
- data/doc/cxxapi/classPassenger_1_1IOException-members.html +1 -1
- data/doc/cxxapi/classPassenger_1_1IOException.html +1 -1
- data/doc/cxxapi/classPassenger_1_1MessageChannel-members.html +1 -1
- data/doc/cxxapi/classPassenger_1_1MessageChannel.html +1 -1
- data/doc/cxxapi/classPassenger_1_1SpawnException-members.html +1 -1
- data/doc/cxxapi/classPassenger_1_1SpawnException.html +1 -1
- data/doc/cxxapi/classPassenger_1_1SpawnManager-members.html +1 -1
- data/doc/cxxapi/classPassenger_1_1SpawnManager.html +1 -1
- data/doc/cxxapi/classPassenger_1_1StandardApplicationPool-members.html +1 -1
- data/doc/cxxapi/classPassenger_1_1StandardApplicationPool.html +1 -1
- data/doc/cxxapi/classPassenger_1_1SystemException-members.html +1 -1
- data/doc/cxxapi/classPassenger_1_1SystemException.html +1 -1
- data/doc/cxxapi/definitions_8h-source.html +1 -1
- data/doc/cxxapi/files.html +1 -1
- data/doc/cxxapi/functions.html +1 -1
- data/doc/cxxapi/functions_func.html +1 -1
- data/doc/cxxapi/functions_type.html +1 -1
- data/doc/cxxapi/graph_legend.html +1 -1
- data/doc/cxxapi/graph_legend.png +0 -0
- data/doc/cxxapi/group__Configuration.html +3 -3
- data/doc/cxxapi/group__Configuration.png +0 -0
- data/doc/cxxapi/group__Core.html +1 -1
- data/doc/cxxapi/group__Core.png +0 -0
- data/doc/cxxapi/group__Exceptions.html +1 -1
- data/doc/cxxapi/group__Hooks.html +1 -1
- data/doc/cxxapi/group__Hooks.png +0 -0
- data/doc/cxxapi/group__Support.html +1 -1
- data/doc/cxxapi/hierarchy.html +1 -1
- data/doc/cxxapi/inherit__graph__0.png +0 -0
- data/doc/cxxapi/inherit__graph__1.png +0 -0
- data/doc/cxxapi/inherit__graph__10.map +1 -0
- data/doc/cxxapi/inherit__graph__10.md5 +1 -0
- data/doc/cxxapi/inherit__graph__10.png +0 -0
- data/doc/cxxapi/inherit__graph__2.png +0 -0
- data/doc/cxxapi/inherit__graph__3.png +0 -0
- data/doc/cxxapi/inherit__graph__4.png +0 -0
- data/doc/cxxapi/inherit__graph__5.png +0 -0
- data/doc/cxxapi/inherit__graph__6.png +0 -0
- data/doc/cxxapi/inherit__graph__7.png +0 -0
- data/doc/cxxapi/inherit__graph__8.png +0 -0
- data/doc/cxxapi/inherit__graph__9.png +0 -0
- data/doc/cxxapi/inherits.html +1 -1
- data/doc/cxxapi/main.html +1 -1
- data/doc/cxxapi/modules.html +1 -1
- data/doc/cxxapi/structPassenger_1_1AnythingToString-members.html +1 -1
- data/doc/cxxapi/structPassenger_1_1AnythingToString.html +1 -1
- data/doc/cxxapi/structPassenger_1_1AnythingToString_3_01vector_3_01string_01_4_01_4-members.html +1 -1
- data/doc/cxxapi/structPassenger_1_1AnythingToString_3_01vector_3_01string_01_4_01_4.html +1 -1
- data/doc/rdoc/classes/Passenger/RequestHandler.html +84 -74
- data/doc/rdoc/classes/Passenger/SpawnManager.html +54 -49
- data/doc/rdoc/classes/PlatformInfo.html +25 -12
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/DEVELOPERS_TXT.html +1 -1
- data/doc/rdoc/files/ext/passenger/native_support_c.html +1 -1
- data/doc/rdoc/files/lib/passenger/abstract_server_rb.html +1 -1
- data/doc/rdoc/files/lib/passenger/application_spawner_rb.html +1 -1
- data/doc/rdoc/files/lib/passenger/dependencies_rb.html +1 -1
- data/doc/rdoc/files/lib/passenger/framework_spawner_rb.html +1 -1
- data/doc/rdoc/files/lib/passenger/platform_info_rb.html +1 -1
- data/doc/rdoc/files/lib/passenger/request_handler_rb.html +1 -1
- data/doc/rdoc/files/lib/passenger/spawn_manager_rb.html +1 -1
- data/ext/apache2/Configuration.h +1 -1
- data/ext/apache2/Hooks.cpp +68 -16
- data/ext/apache2/Logging.cpp +1 -1
- data/ext/apache2/MessageChannel.h +48 -43
- data/ext/passenger/native_support.c +46 -43
- data/lib/passenger/application_spawner.rb +37 -4
- data/lib/passenger/dependencies.rb +5 -1
- data/lib/passenger/framework_spawner.rb +2 -0
- data/lib/passenger/platform_info.rb +32 -17
- data/lib/passenger/request_handler.rb +10 -1
- data/lib/passenger/spawn_manager.rb +14 -8
- data/lib/passenger/templates/error_layout.html.erb +2 -2
- data/test/CxxTestMain.cpp +1 -0
- data/test/MessageChannelTest.cpp +3 -1
- data/test/application_spawner_spec.rb +2 -0
- data/test/framework_spawner_spec.rb +2 -0
- data/test/integration_tests.rb +1 -0
- data/test/spawn_manager_spec.rb +2 -0
- data/test/spawner_privilege_lowering_spec.rb +1 -0
- data/test/stub/minimal-railsapp/vendor/rails/actionpack/lib/action_controller.rb +4 -0
- data/test/stub/minimal-railsapp/vendor/rails/activerecord/lib/active_record.rb +7 -0
- data/test/stub/rails_apps/foobar/config/environments/test.rb +22 -0
- metadata +28 -22
- data/lib/passenger/templates/osx_broken_apache_warning.txt.erb +0 -23
@@ -184,19 +184,19 @@ href="SpawnManager.html">SpawnManager</a> is no longer needed.
|
|
184
184
|
<p class="source-link">[ <a href="javascript:toggleSource('M000048_source')" id="l_M000048_source">show source</a> ]</p>
|
185
185
|
<div id="M000048_source" class="dyn-source">
|
186
186
|
<pre>
|
187
|
-
<span class="ruby-comment cmt"># File lib/passenger/spawn_manager.rb, line
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
187
|
+
<span class="ruby-comment cmt"># File lib/passenger/spawn_manager.rb, line 165</span>
|
188
|
+
165: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cleanup</span>
|
189
|
+
166: <span class="ruby-ivar">@lock</span>.<span class="ruby-identifier">synchronize</span> <span class="ruby-keyword kw">do</span>
|
190
|
+
167: <span class="ruby-ivar">@cond</span>.<span class="ruby-identifier">signal</span>
|
191
|
+
168: <span class="ruby-keyword kw">end</span>
|
192
|
+
169: <span class="ruby-ivar">@cleaner_thread</span>.<span class="ruby-identifier">join</span>
|
193
|
+
170: <span class="ruby-ivar">@lock</span>.<span class="ruby-identifier">synchronize</span> <span class="ruby-keyword kw">do</span>
|
194
|
+
171: <span class="ruby-ivar">@spawners</span>.<span class="ruby-identifier">each_value</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">spawner</span><span class="ruby-operator">|</span>
|
195
|
+
172: <span class="ruby-identifier">spawner</span>.<span class="ruby-identifier">stop</span>
|
196
|
+
173: <span class="ruby-keyword kw">end</span>
|
197
|
+
174: <span class="ruby-ivar">@spawners</span>.<span class="ruby-identifier">clear</span>
|
198
|
+
175: <span class="ruby-keyword kw">end</span>
|
199
|
+
176: <span class="ruby-keyword kw">end</span>
|
200
200
|
</pre>
|
201
201
|
</div>
|
202
202
|
</div>
|
@@ -228,32 +228,32 @@ Raises AbstractServer::SpawnError if something went wrong.
|
|
228
228
|
<p class="source-link">[ <a href="javascript:toggleSource('M000047_source')" id="l_M000047_source">show source</a> ]</p>
|
229
229
|
<div id="M000047_source" class="dyn-source">
|
230
230
|
<pre>
|
231
|
-
<span class="ruby-comment cmt"># File lib/passenger/spawn_manager.rb, line
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
231
|
+
<span class="ruby-comment cmt"># File lib/passenger/spawn_manager.rb, line 138</span>
|
232
|
+
138: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reload</span>(<span class="ruby-identifier">app_root</span> = <span class="ruby-keyword kw">nil</span>)
|
233
|
+
139: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">app_root</span>
|
234
|
+
140: <span class="ruby-keyword kw">begin</span>
|
235
|
+
141: <span class="ruby-identifier">app_root</span> = <span class="ruby-identifier">normalize_path</span>(<span class="ruby-identifier">app_root</span>)
|
236
|
+
142: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">ArgumentError</span>
|
237
|
+
143: <span class="ruby-keyword kw">end</span>
|
238
|
+
144: <span class="ruby-keyword kw">end</span>
|
239
|
+
145: <span class="ruby-ivar">@lock</span>.<span class="ruby-identifier">synchronize</span> <span class="ruby-keyword kw">do</span>
|
240
|
+
146: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">app_root</span>
|
241
|
+
147: <span class="ruby-comment cmt"># Delete associated ApplicationSpawner.</span>
|
242
|
+
148: <span class="ruby-identifier">key</span> = <span class="ruby-node">"app:#{app_root}"</span>
|
243
|
+
149: <span class="ruby-identifier">spawner</span> = <span class="ruby-ivar">@spawners</span>[<span class="ruby-identifier">key</span>]
|
244
|
+
150: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">spawner</span>
|
245
|
+
151: <span class="ruby-identifier">spawner</span>.<span class="ruby-identifier">stop</span>
|
246
|
+
152: <span class="ruby-ivar">@spawners</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">key</span>)
|
247
|
+
153: <span class="ruby-keyword kw">end</span>
|
248
|
+
154: <span class="ruby-keyword kw">end</span>
|
249
|
+
155: <span class="ruby-ivar">@spawners</span>.<span class="ruby-identifier">each_value</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">spawner</span><span class="ruby-operator">|</span>
|
250
|
+
156: <span class="ruby-comment cmt"># Reload FrameworkSpawners.</span>
|
251
|
+
157: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">spawner</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:reload</span>)
|
252
|
+
158: <span class="ruby-identifier">spawner</span>.<span class="ruby-identifier">reload</span>(<span class="ruby-identifier">app_root</span>)
|
253
|
+
159: <span class="ruby-keyword kw">end</span>
|
254
|
+
160: <span class="ruby-keyword kw">end</span>
|
255
|
+
161: <span class="ruby-keyword kw">end</span>
|
256
|
+
162: <span class="ruby-keyword kw">end</span>
|
257
257
|
</pre>
|
258
258
|
</div>
|
259
259
|
</div>
|
@@ -351,16 +351,21 @@ exception or called exit() during startup.
|
|
351
351
|
106: <span class="ruby-identifier">spawner</span>.<span class="ruby-identifier">start</span>
|
352
352
|
107: <span class="ruby-ivar">@spawners</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">spawner</span>
|
353
353
|
108: <span class="ruby-keyword kw">end</span>
|
354
|
-
109:
|
355
|
-
110:
|
356
|
-
111:
|
357
|
-
112:
|
358
|
-
113:
|
359
|
-
114: <span class="ruby-
|
360
|
-
115:
|
361
|
-
116:
|
362
|
-
117:
|
363
|
-
118:
|
354
|
+
109: <span class="ruby-identifier">spawner</span>.<span class="ruby-identifier">time</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
|
355
|
+
110: <span class="ruby-keyword kw">begin</span>
|
356
|
+
111: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">spawner</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">FrameworkSpawner</span>)
|
357
|
+
112: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">spawner</span>.<span class="ruby-identifier">spawn_application</span>(<span class="ruby-identifier">app_root</span>, <span class="ruby-identifier">lower_privilege</span>,
|
358
|
+
113: <span class="ruby-identifier">lowest_user</span>)
|
359
|
+
114: <span class="ruby-keyword kw">else</span>
|
360
|
+
115: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">spawner</span>.<span class="ruby-identifier">spawn_application</span>
|
361
|
+
116: <span class="ruby-keyword kw">end</span>
|
362
|
+
117: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">AbstractServer</span><span class="ruby-operator">::</span><span class="ruby-constant">ServerError</span>
|
363
|
+
118: <span class="ruby-identifier">spawner</span>.<span class="ruby-identifier">stop</span>
|
364
|
+
119: <span class="ruby-ivar">@spawners</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">key</span>)
|
365
|
+
120: <span class="ruby-identifier">raise</span>
|
366
|
+
121: <span class="ruby-keyword kw">end</span>
|
367
|
+
122: <span class="ruby-keyword kw">end</span>
|
368
|
+
123: <span class="ruby-keyword kw">end</span>
|
364
369
|
</pre>
|
365
370
|
</div>
|
366
371
|
</div>
|
@@ -177,6 +177,19 @@ The absolute path to the ‘apachectl’ or
|
|
177
177
|
The absolute path to the Apache binary (that is, ‘httpd’,
|
178
178
|
‘httpd2’, ‘apache’ or ‘apache2’).
|
179
179
|
|
180
|
+
</td>
|
181
|
+
</tr>
|
182
|
+
<tr valign='top'>
|
183
|
+
<td class="attr-name">APR_CONFIG</td>
|
184
|
+
<td>=</td>
|
185
|
+
<td class="attr-value">find_apr_config</td>
|
186
|
+
</tr>
|
187
|
+
<tr valign='top'>
|
188
|
+
<td> </td>
|
189
|
+
<td colspan="2" class="attr-desc">
|
190
|
+
The absolute path to the ‘apr-config’ or
|
191
|
+
‘apr-1-config’ executable.
|
192
|
+
|
180
193
|
</td>
|
181
194
|
</tr>
|
182
195
|
<tr valign='top'>
|
@@ -192,9 +205,9 @@ The C compiler flags that are necessary to compile an Apache module.
|
|
192
205
|
</td>
|
193
206
|
</tr>
|
194
207
|
<tr valign='top'>
|
195
|
-
<td class="attr-name">
|
208
|
+
<td class="attr-name">APR_LIBS</td>
|
196
209
|
<td>=</td>
|
197
|
-
<td class="attr-value">
|
210
|
+
<td class="attr-value">determine_apr_info</td>
|
198
211
|
</tr>
|
199
212
|
<tr valign='top'>
|
200
213
|
<td class="attr-name">MULTI_ARCH_FLAGS</td>
|
@@ -257,16 +270,16 @@ always behave correctly, for some weird reason.
|
|
257
270
|
<p class="source-link">[ <a href="javascript:toggleSource('M000007_source')" id="l_M000007_source">show source</a> ]</p>
|
258
271
|
<div id="M000007_source" class="dyn-source">
|
259
272
|
<pre>
|
260
|
-
<span class="ruby-comment cmt"># File lib/passenger/platform_info.rb, line
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
273
|
+
<span class="ruby-comment cmt"># File lib/passenger/platform_info.rb, line 222</span>
|
274
|
+
222: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">find_command</span>(<span class="ruby-identifier">name</span>)
|
275
|
+
223: <span class="ruby-constant">ENV</span>[<span class="ruby-value str">'PATH'</span>].<span class="ruby-identifier">split</span>(<span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">PATH_SEPARATOR</span>).<span class="ruby-identifier">detect</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">directory</span><span class="ruby-operator">|</span>
|
276
|
+
224: <span class="ruby-identifier">path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">directory</span>, <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>)
|
277
|
+
225: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">executable?</span>(<span class="ruby-identifier">path</span>)
|
278
|
+
226: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">path</span>
|
279
|
+
227: <span class="ruby-keyword kw">end</span>
|
280
|
+
228: <span class="ruby-keyword kw">end</span>
|
281
|
+
229: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
|
282
|
+
230: <span class="ruby-keyword kw">end</span>
|
270
283
|
</pre>
|
271
284
|
</div>
|
272
285
|
</div>
|
data/doc/rdoc/created.rid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Tue, 29 Apr 2008 15:25:26 +0200
|
data/ext/apache2/Configuration.h
CHANGED
data/ext/apache2/Hooks.cpp
CHANGED
@@ -259,6 +259,33 @@ private:
|
|
259
259
|
buffer.append(hdrs[i].val);
|
260
260
|
buffer.append(1, '\0');
|
261
261
|
}
|
262
|
+
|
263
|
+
/*
|
264
|
+
* If the last header value is an empty string, then the buffer
|
265
|
+
* will end with "\0\0". For example, if 'SSLOptions +ExportCertData'
|
266
|
+
* is set, and there's no client certificate, and 'SSL_CLIENT_CERT'
|
267
|
+
* is the last header, then the buffer will end with:
|
268
|
+
*
|
269
|
+
* "SSL_CLIENT_CERT\0\0"
|
270
|
+
*
|
271
|
+
* The data in the buffer will be processed by the RequestHandler class,
|
272
|
+
* which is implemented in Ruby. But it uses Hash[*data.split("\0")] to
|
273
|
+
* unserialize the data. Unfortunately String#split will not transform
|
274
|
+
* the trailing "\0\0" into an empty string:
|
275
|
+
*
|
276
|
+
* "SSL_CLIENT_CERT\0\0".split("\0")
|
277
|
+
* # => desired result: ["SSL_CLIENT_CERT", ""]
|
278
|
+
* # => actual result: ["SSL_CLIENT_CERT"]
|
279
|
+
*
|
280
|
+
* When that happens, Hash[..] will raise an ArgumentError because
|
281
|
+
* data.split("\0") does not return an array with a length that is a
|
282
|
+
* multiple of 2.
|
283
|
+
*
|
284
|
+
* So here, we add a dummy header to prevent situations like that from
|
285
|
+
* happening.
|
286
|
+
*/
|
287
|
+
buffer.append("_\0_\0", 4);
|
288
|
+
|
262
289
|
session->sendHeaders(buffer);
|
263
290
|
return APR_SUCCESS;
|
264
291
|
}
|
@@ -329,7 +356,7 @@ public:
|
|
329
356
|
applicationPool->setMax(config->maxPoolSize);
|
330
357
|
applicationPool->setMaxIdleTime(config->poolIdleTime);
|
331
358
|
} catch (const exception &e) {
|
332
|
-
fprintf(stderr, "*** Cannot initialize Passenger: %s", e.what());
|
359
|
+
fprintf(stderr, "*** Cannot initialize Passenger: %s\n", e.what());
|
333
360
|
fflush(stderr);
|
334
361
|
abort();
|
335
362
|
}
|
@@ -351,9 +378,12 @@ public:
|
|
351
378
|
} else if (!verifyRailsDir(railsDir)) {
|
352
379
|
ap_set_content_type(r, "text/html; charset=UTF-8");
|
353
380
|
ap_rputs("<h1>Passenger error #2</h1>\n", r);
|
354
|
-
ap_rputs("Passenger
|
381
|
+
ap_rputs("Passenger thought that the Rails application's \"public\" directory is \"", r);
|
355
382
|
ap_rputs(ap_escape_html(r->pool, railsDir.c_str()), r);
|
356
|
-
ap_rputs("\",
|
383
|
+
ap_rputs("\". But upon further inspection, it doesn't seem to be a valid Rails ", r);
|
384
|
+
ap_rputs("\"public\" folder. It is possible that Apache doesn't have read ", r);
|
385
|
+
ap_rputs("permissions to your Rails application's folder. Please check your ", r);
|
386
|
+
ap_rputs("file permissions.", r);
|
357
387
|
return OK;
|
358
388
|
}
|
359
389
|
|
@@ -423,9 +453,10 @@ public:
|
|
423
453
|
mapToStorage(request_rec *r) {
|
424
454
|
DirConfig *config = getDirConfig(r);
|
425
455
|
bool forwardToRails;
|
456
|
+
const char *baseURI;
|
426
457
|
|
427
|
-
|
428
|
-
|
458
|
+
baseURI = determineRailsBaseURI(r, config);
|
459
|
+
if (baseURI == NULL || fileExists(r->filename)) {
|
429
460
|
/*
|
430
461
|
* fileExists():
|
431
462
|
* If the file already exists, serve it directly.
|
@@ -487,6 +518,12 @@ public:
|
|
487
518
|
* interfere.
|
488
519
|
*/
|
489
520
|
return OK;
|
521
|
+
} else if (strcmp(r->uri, baseURI) == 0) {
|
522
|
+
/* But we ignore RailsAllowModRewrite for the base URI of
|
523
|
+
* the Rails application. Otherwise, Apache will show a
|
524
|
+
* directory listing. This fixes issue #11.
|
525
|
+
*/
|
526
|
+
return OK;
|
490
527
|
} else {
|
491
528
|
return DECLINED;
|
492
529
|
}
|
@@ -518,24 +555,36 @@ destroy_hooks(void *arg) {
|
|
518
555
|
static int
|
519
556
|
init_module(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) {
|
520
557
|
/*
|
558
|
+
* The Apache initialization process has the following properties:
|
559
|
+
*
|
521
560
|
* 1. Apache on Unix calls the post_config hook twice, once before detach() and once
|
522
561
|
* after. On Windows it never calls detach().
|
523
562
|
* 2. When Apache is compiled to use DSO modules, the modules are unloaded between the
|
524
563
|
* two post_config hook calls.
|
525
|
-
* 3. On Unix, if the -X commandline option is given
|
564
|
+
* 3. On Unix, if the -X commandline option is given (the 'DEBUG' config is set),
|
565
|
+
* detach() will not be called.
|
566
|
+
*
|
567
|
+
* The Passenger initialization process is pretty expensive because a spawn server has
|
568
|
+
* to be started, so we'll want to avoid initializing twice because of property #2.
|
526
569
|
*
|
527
|
-
*
|
528
|
-
*
|
570
|
+
* The most straightforward solution is to initialize Passenger the second time
|
571
|
+
* post_config is called. But unfortunately, that doesn't work if the Passenger
|
572
|
+
* module is loaded after a graceful restart. There also doesn't seem to be any
|
573
|
+
* good hooks that we can use to avoid double initialization.
|
574
|
+
*
|
575
|
+
* So as a hack, we check whether Apache has already been daemonized, by checking
|
576
|
+
* whether ppid() returns 1. This doesn't work with Apache 2.0.x though: ppid()
|
577
|
+
* doesn't return 1. So Apache 2.0.x users will just have to live with the double
|
578
|
+
* initialization overhead.
|
529
579
|
*/
|
530
|
-
|
531
|
-
apr_pool_t *processPool = s->process->pool;
|
580
|
+
bool passengerShouldBeInitialized;
|
532
581
|
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
582
|
+
#if (AP_SERVER_MAJORVERSION_NUMBER == 2 && AP_SERVER_MINORVERSION_NUMBER >= 2) || AP_SERVER_MAJORVERSION_NUMBER > 2
|
583
|
+
passengerShouldBeInitialized = getppid() == 1 || ap_exists_config_define("DEBUG");
|
584
|
+
#else
|
585
|
+
passengerShouldBeInitialized = true;
|
586
|
+
#endif
|
587
|
+
if (passengerShouldBeInitialized) {
|
539
588
|
try {
|
540
589
|
hooks = new Hooks(pconf, plog, ptemp, s);
|
541
590
|
apr_pool_cleanup_register(pconf, NULL,
|
@@ -586,6 +635,8 @@ init_module(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *
|
|
586
635
|
hooks = NULL;
|
587
636
|
return DECLINED;
|
588
637
|
}
|
638
|
+
} else {
|
639
|
+
return OK;
|
589
640
|
}
|
590
641
|
}
|
591
642
|
|
@@ -628,3 +679,4 @@ passenger_register_hooks(apr_pool_t *p) {
|
|
628
679
|
/**
|
629
680
|
* @}
|
630
681
|
*/
|
682
|
+
|
data/ext/apache2/Logging.cpp
CHANGED
@@ -256,31 +256,33 @@ public:
|
|
256
256
|
* @see readFileDescriptor()
|
257
257
|
*/
|
258
258
|
void writeFileDescriptor(int fileDescriptor) {
|
259
|
-
struct msghdr msg;
|
260
|
-
struct iovec vec[1];
|
261
|
-
char buf[1];
|
262
259
|
struct {
|
263
|
-
struct cmsghdr
|
260
|
+
struct cmsghdr header;
|
264
261
|
int fd;
|
265
|
-
}
|
266
|
-
|
262
|
+
} control;
|
263
|
+
|
264
|
+
control.header.cmsg_len = sizeof(control);
|
265
|
+
control.header.cmsg_level = SOL_SOCKET;
|
266
|
+
control.header.cmsg_type = SCM_RIGHTS;
|
267
|
+
control.fd = fileDescriptor;
|
268
|
+
|
269
|
+
struct msghdr msg;
|
270
|
+
struct iovec vec;
|
271
|
+
char dummy[1];
|
272
|
+
|
267
273
|
msg.msg_name = NULL;
|
268
274
|
msg.msg_namelen = 0;
|
269
|
-
|
270
|
-
/* Linux and Solaris
|
271
|
-
|
272
|
-
vec
|
273
|
-
vec
|
274
|
-
msg.msg_iov
|
275
|
+
|
276
|
+
/* Linux and Solaris require msg_iov to be non-NULL.. */
|
277
|
+
dummy[0] = '\0';
|
278
|
+
vec.iov_base = dummy;
|
279
|
+
vec.iov_len = sizeof(dummy);
|
280
|
+
msg.msg_iov = &vec;
|
275
281
|
msg.msg_iovlen = 1;
|
276
|
-
|
277
|
-
msg.msg_control
|
278
|
-
msg.msg_controllen =
|
279
|
-
msg.msg_flags
|
280
|
-
cmsg.hdr.cmsg_len = CMSG_LEN(sizeof(int));
|
281
|
-
cmsg.hdr.cmsg_level = SOL_SOCKET;
|
282
|
-
cmsg.hdr.cmsg_type = SCM_RIGHTS;
|
283
|
-
cmsg.fd = fileDescriptor;
|
282
|
+
|
283
|
+
msg.msg_control = (caddr_t) &control;
|
284
|
+
msg.msg_controllen = sizeof(control);
|
285
|
+
msg.msg_flags = 0;
|
284
286
|
|
285
287
|
if (sendmsg(fd, &msg, 0) == -1) {
|
286
288
|
throw SystemException("Cannot send file descriptor with sendmsg()", errno);
|
@@ -420,41 +422,44 @@ public:
|
|
420
422
|
* file descriptor.
|
421
423
|
*/
|
422
424
|
int readFileDescriptor() {
|
423
|
-
struct msghdr msg;
|
424
|
-
struct iovec vec[2];
|
425
|
-
char buf[1];
|
426
425
|
struct {
|
427
|
-
struct cmsghdr
|
426
|
+
struct cmsghdr header;
|
428
427
|
int fd;
|
429
|
-
}
|
428
|
+
} control;
|
430
429
|
|
431
|
-
|
430
|
+
control.header.cmsg_len = sizeof(control);
|
431
|
+
control.header.cmsg_level = SOL_SOCKET;
|
432
|
+
control.header.cmsg_type = SCM_RIGHTS;
|
433
|
+
control.fd = -1;
|
434
|
+
|
435
|
+
struct msghdr msg;
|
436
|
+
struct iovec vec;
|
437
|
+
char dummy[1];
|
438
|
+
|
439
|
+
msg.msg_name = NULL;
|
432
440
|
msg.msg_namelen = 0;
|
433
|
-
|
434
|
-
|
435
|
-
vec
|
436
|
-
|
441
|
+
|
442
|
+
dummy[0] = '\0';
|
443
|
+
vec.iov_base = dummy;
|
444
|
+
vec.iov_len = sizeof(dummy);
|
445
|
+
msg.msg_iov = &vec;
|
437
446
|
msg.msg_iovlen = 1;
|
438
447
|
|
439
|
-
msg.msg_control
|
440
|
-
msg.msg_controllen =
|
441
|
-
msg.msg_flags
|
442
|
-
cmsg.hdr.cmsg_len = CMSG_LEN(sizeof(int));
|
443
|
-
cmsg.hdr.cmsg_level = SOL_SOCKET;
|
444
|
-
cmsg.hdr.cmsg_type = SCM_RIGHTS;
|
445
|
-
cmsg.fd = -1;
|
448
|
+
msg.msg_control = (caddr_t) &control;
|
449
|
+
msg.msg_controllen = sizeof(control);
|
450
|
+
msg.msg_flags = 0;
|
446
451
|
|
447
452
|
if (recvmsg(fd, &msg, 0) == -1) {
|
448
453
|
throw SystemException("Cannot read file descriptor with recvmsg()", errno);
|
449
454
|
}
|
450
|
-
|
451
|
-
if (msg.msg_controllen
|
452
|
-
||
|
453
|
-
||
|
454
|
-
||
|
455
|
+
|
456
|
+
if (msg.msg_controllen != sizeof(control)
|
457
|
+
|| control.header.cmsg_len != sizeof(control)
|
458
|
+
|| control.header.cmsg_level != SOL_SOCKET
|
459
|
+
|| control.header.cmsg_type != SCM_RIGHTS) {
|
455
460
|
throw IOException("No valid file descriptor received.");
|
456
461
|
}
|
457
|
-
return
|
462
|
+
return control.fd;
|
458
463
|
}
|
459
464
|
};
|
460
465
|
|