passenger 4.0.48 → 4.0.49
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of passenger might be problematic. Click here for more details.
- checksums.yaml +8 -8
- checksums.yaml.gz.asc +7 -7
- data.tar.gz.asc +7 -7
- data/.editorconfig +36 -2
- data/.travis.yml +1 -1
- data/CHANGELOG +16 -0
- data/Rakefile +0 -1
- data/build/apache2.rb +4 -4
- data/build/common_library.rb +18 -18
- data/build/cplusplus_support.rb +2 -2
- data/build/documentation.rb +1 -1
- data/build/integration_tests.rb +12 -4
- data/build/misc.rb +12 -7
- data/build/packaging.rb +14 -14
- data/build/preprocessor.rb +10 -10
- data/build/rake_extensions.rb +11 -11
- data/build/ruby_extension.rb +2 -2
- data/dev/ci/inituidgid +24 -0
- data/dev/ci/run_jenkins.sh +57 -0
- data/dev/ci/run_rpm_tests.sh +77 -0
- data/dev/{run_travis.sh → ci/run_travis.sh} +60 -4
- data/doc/Users guide Nginx.txt +2 -2
- data/doc/users_guide_snippets/environment_variables.txt +0 -2
- data/doc/users_guide_snippets/tips.txt +20 -1
- data/ext/apache2/Bucket.cpp +18 -18
- data/ext/apache2/Bucket.h +4 -4
- data/ext/apache2/Configuration.cpp +7 -7
- data/ext/apache2/Configuration.hpp +43 -43
- data/ext/apache2/DirectoryMapper.h +5 -5
- data/ext/apache2/Hooks.cpp +142 -142
- data/ext/apache2/MergeDirConfig.cpp +40 -40
- data/ext/common/Account.h +17 -17
- data/ext/common/AccountsDatabase.h +9 -9
- data/ext/common/AgentsStarter.cpp +2 -2
- data/ext/common/AgentsStarter.h +40 -40
- data/ext/common/ApplicationPool2/Common.h +10 -6
- data/ext/common/ApplicationPool2/ComponentInfo.h +2 -2
- data/ext/common/ApplicationPool2/DirectSpawner.h +17 -17
- data/ext/common/ApplicationPool2/DummySpawner.h +5 -5
- data/ext/common/ApplicationPool2/Group.h +54 -38
- data/ext/common/ApplicationPool2/Implementation.cpp +76 -49
- data/ext/common/ApplicationPool2/Options.h +98 -91
- data/ext/common/ApplicationPool2/Pool.h +70 -69
- data/ext/common/ApplicationPool2/Process.h +21 -21
- data/ext/common/ApplicationPool2/Session.h +11 -11
- data/ext/common/ApplicationPool2/SmartSpawner.h +60 -60
- data/ext/common/ApplicationPool2/Socket.h +19 -19
- data/ext/common/ApplicationPool2/Spawner.h +64 -72
- data/ext/common/ApplicationPool2/SpawnerFactory.h +4 -4
- data/ext/common/ApplicationPool2/SuperGroup.h +41 -41
- data/ext/common/BackgroundEventLoop.cpp +1 -1
- data/ext/common/BackgroundEventLoop.h +2 -2
- data/ext/common/Constants.h +1 -1
- data/ext/common/EventedBufferedInput.h +5 -5
- data/ext/common/EventedClient.h +51 -51
- data/ext/common/EventedMessageServer.h +39 -39
- data/ext/common/EventedServer.h +32 -32
- data/ext/common/Exceptions.h +23 -23
- data/ext/common/FileDescriptor.h +18 -18
- data/ext/common/Logging.cpp +1 -1
- data/ext/common/MessageClient.h +27 -27
- data/ext/common/MessageReadersWriters.h +79 -79
- data/ext/common/MessageServer.h +59 -59
- data/ext/common/RandomGenerator.h +12 -12
- data/ext/common/ResourceLocator.h +8 -8
- data/ext/common/SafeLibev.h +54 -25
- data/ext/common/ServerInstanceDir.h +31 -31
- data/ext/common/StaticString.h +50 -48
- data/ext/common/Utils.cpp +73 -78
- data/ext/common/Utils.h +6 -6
- data/ext/common/Utils/Base64.cpp +3 -3
- data/ext/common/Utils/Base64.h +7 -7
- data/ext/common/Utils/BlockingQueue.h +9 -9
- data/ext/common/Utils/BufferedIO.h +17 -17
- data/ext/common/Utils/CachedFileStat.hpp +16 -16
- data/ext/common/Utils/Dechunker.h +25 -25
- data/ext/common/Utils/FileChangeChecker.h +10 -10
- data/ext/common/Utils/MemZeroGuard.h +5 -5
- data/ext/common/Utils/MemoryBarrier.h +1 -1
- data/ext/common/Utils/MessageIO.h +61 -61
- data/ext/common/Utils/ProcessMetricsCollector.h +40 -40
- data/ext/common/Utils/ScopeGuard.h +7 -7
- data/ext/common/Utils/SpeedMeter.h +1 -1
- data/ext/common/Utils/StrIntUtils.cpp +13 -13
- data/ext/common/Utils/StrIntUtils.h +3 -3
- data/ext/common/Utils/StringScanning.h +5 -5
- data/ext/common/Utils/SystemMetricsCollector.h +2 -2
- data/ext/common/Utils/SystemTime.h +10 -10
- data/ext/common/Utils/Template.h +2 -2
- data/ext/common/Utils/Timer.h +6 -6
- data/ext/common/Utils/VariantMap.h +29 -29
- data/ext/common/agents/Base.cpp +19 -19
- data/ext/common/agents/HelperAgent/AgentOptions.h +1 -1
- data/ext/common/agents/HelperAgent/FileBackedPipe.h +6 -6
- data/ext/common/agents/HelperAgent/Main.cpp +44 -43
- data/ext/common/agents/HelperAgent/RequestHandler.cpp +4 -4
- data/ext/common/agents/HelperAgent/RequestHandler.h +29 -28
- data/ext/common/agents/HelperAgent/ScgiRequestParser.h +56 -50
- data/ext/common/agents/LoggingAgent/AdminController.h +8 -8
- data/ext/common/agents/LoggingAgent/DataStoreId.h +17 -17
- data/ext/common/agents/LoggingAgent/FilterSupport.h +167 -167
- data/ext/common/agents/LoggingAgent/LoggingServer.h +122 -122
- data/ext/common/agents/LoggingAgent/Main.cpp +7 -7
- data/ext/common/agents/LoggingAgent/RemoteSender.h +54 -54
- data/ext/common/agents/SpawnPreparer.cpp +4 -4
- data/ext/common/agents/TempDirToucher.c +2 -2
- data/ext/common/agents/Watchdog/AgentWatcher.cpp +47 -47
- data/ext/common/agents/Watchdog/HelperAgentWatcher.cpp +7 -7
- data/ext/common/agents/Watchdog/LoggingAgentWatcher.cpp +7 -7
- data/ext/common/agents/Watchdog/Main.cpp +22 -22
- data/ext/common/agents/Watchdog/ServerInstanceDirToucher.cpp +9 -9
- data/ext/libeio/eio.c +1 -1
- data/ext/nginx/Configuration.c +30 -30
- data/ext/nginx/Configuration.h +1 -1
- data/ext/nginx/ContentHandler.c +54 -54
- data/ext/nginx/ContentHandler.h +3 -3
- data/ext/nginx/StaticContentHandler.c +2 -2
- data/ext/nginx/ngx_http_passenger_module.c +21 -21
- data/ext/oxt/detail/backtrace_enabled.hpp +1 -1
- data/ext/oxt/detail/context.hpp +1 -1
- data/ext/oxt/detail/spin_lock_darwin.hpp +4 -4
- data/ext/oxt/detail/spin_lock_gcc_x86.hpp +3 -3
- data/ext/oxt/detail/spin_lock_pthreads.hpp +4 -4
- data/ext/oxt/detail/tracable_exception_disabled.hpp +1 -1
- data/ext/oxt/dynamic_thread_group.hpp +18 -18
- data/ext/oxt/implementation.cpp +9 -8
- data/ext/oxt/macros.hpp +2 -2
- data/ext/oxt/system_calls.cpp +11 -11
- data/ext/oxt/system_calls.hpp +13 -13
- data/ext/oxt/thread.hpp +22 -14
- data/ext/ruby/passenger_native_support.c +55 -55
- data/lib/phusion_passenger.rb +24 -24
- data/lib/phusion_passenger/common_library.rb +2 -0
- data/lib/phusion_passenger/loader_shared_helpers.rb +18 -18
- data/lib/phusion_passenger/packaging.rb +9 -4
- data/lib/phusion_passenger/platform_info/apache.rb +45 -31
- data/lib/phusion_passenger/platform_info/compiler.rb +11 -11
- data/lib/phusion_passenger/rack/thread_handler_extension.rb +1 -1
- data/lib/phusion_passenger/request_handler/thread_handler.rb +8 -8
- data/lib/phusion_passenger/standalone/app_finder.rb +16 -16
- data/lib/phusion_passenger/standalone/command.rb +22 -22
- data/packaging/rpm/LICENSE.txt +19 -0
- data/packaging/rpm/Makefile +13 -0
- data/packaging/rpm/README.md +41 -0
- data/packaging/rpm/Vagrantfile +38 -0
- data/{rpm/Vagrantfile → packaging/rpm/Vagrantfile.centos} +0 -0
- data/packaging/rpm/build +170 -0
- data/packaging/rpm/create_project +41 -0
- data/packaging/rpm/git_update +88 -0
- data/packaging/rpm/image/Dockerfile +37 -0
- data/packaging/rpm/image/Gemfile +3 -0
- data/packaging/rpm/image/Gemfile.lock +12 -0
- data/packaging/rpm/image/RPM-GPG-KEY-amazon-ga +19 -0
- data/packaging/rpm/image/amazon2014-i386.cfg +96 -0
- data/packaging/rpm/image/amazon2014-x86_64.cfg +96 -0
- data/packaging/rpm/image/site-defaults.cfg +168 -0
- data/packaging/rpm/internal/build_tasks.rb +238 -0
- data/packaging/rpm/internal/dummygpg +11 -0
- data/packaging/rpm/internal/exec_build +42 -0
- data/packaging/rpm/internal/get_distro_arch +14 -0
- data/packaging/rpm/internal/get_distro_id +10 -0
- data/packaging/rpm/internal/git_update +27 -0
- data/packaging/rpm/internal/inituidgid +17 -0
- data/packaging/rpm/internal/my_init +344 -0
- data/packaging/rpm/internal/python27 +3 -0
- data/packaging/rpm/internal/repo_update +46 -0
- data/packaging/rpm/internal/setuser +26 -0
- data/packaging/rpm/internal/tracking_helper +40 -0
- data/packaging/rpm/jenkins_release +99 -0
- data/packaging/rpm/lib/build_tasks_support.rb +402 -0
- data/packaging/rpm/lib/preprocessor.rb +341 -0
- data/packaging/rpm/nginx_spec/404.html +119 -0
- data/packaging/rpm/nginx_spec/50x.html +119 -0
- data/packaging/rpm/nginx_spec/index.html +116 -0
- data/packaging/rpm/nginx_spec/nginx-auto-cc-gcc.patch +13 -0
- data/packaging/rpm/nginx_spec/nginx-logo.png +0 -0
- data/packaging/rpm/nginx_spec/nginx-upgrade +13 -0
- data/packaging/rpm/nginx_spec/nginx-upgrade.8 +151 -0
- data/packaging/rpm/nginx_spec/nginx.conf +131 -0
- data/packaging/rpm/nginx_spec/nginx.init +144 -0
- data/packaging/rpm/nginx_spec/nginx.logrotate +13 -0
- data/packaging/rpm/nginx_spec/nginx.service +15 -0
- data/packaging/rpm/nginx_spec/nginx.spec.template +559 -0
- data/packaging/rpm/nginx_spec/nginx.sysconfig +4 -0
- data/packaging/rpm/nginx_spec/passenger.conf +9 -0
- data/packaging/rpm/nginx_spec/poweredby.png +0 -0
- data/{rpm → packaging/rpm/passenger_spec}/apache-passenger.conf.in +0 -0
- data/{rpm → packaging/rpm/passenger_spec}/config.json +0 -0
- data/{rpm → packaging/rpm/passenger_spec}/passenger.logrotate +0 -0
- data/{rpm → packaging/rpm/passenger_spec}/passenger.spec.template +58 -31
- data/{rpm → packaging/rpm/passenger_spec}/passenger_dynamic_thread_group.patch +0 -0
- data/{rpm → packaging/rpm/passenger_spec}/passenger_tests_default_config_example.patch +0 -0
- data/{rpm → packaging/rpm/passenger_spec}/rubygem-passenger-4.0.18-GLIBC_HAVE_LONG_LONG.patch +0 -0
- data/{rpm → packaging/rpm/passenger_spec}/rubygem-passenger-4.0.18-gcc47-include-sys_types.patch +0 -0
- data/packaging/rpm/repo_update +114 -0
- data/packaging/rpm/setup-system +60 -0
- data/packaging/rpm/shell +10 -0
- data/resources/templates/standalone/config.erb +3 -1
- data/test/config.json.rpm-automation +1 -1
- data/test/cxx/ApplicationPool2/DirectSpawnerTest.cpp +11 -11
- data/test/cxx/ApplicationPool2/OptionsTest.cpp +5 -5
- data/test/cxx/ApplicationPool2/PoolTest.cpp +129 -89
- data/test/cxx/ApplicationPool2/ProcessTest.cpp +15 -15
- data/test/cxx/ApplicationPool2/SmartSpawnerTest.cpp +22 -22
- data/test/cxx/ApplicationPool2/SpawnerTestCases.cpp +11 -11
- data/test/cxx/ScgiRequestParserTest.cpp +75 -61
- data/test/cxx/UtilsTest.cpp +86 -85
- data/test/gdbinit.example +3 -0
- data/test/integration_tests/nginx_tests.rb +3 -3
- data/test/integration_tests/source_packaging_test.rb +3 -1
- data/test/stub/nginx/nginx.conf.erb +8 -1
- data/test/support/nginx_controller.rb +7 -7
- metadata +62 -17
- metadata.gz.asc +7 -7
- data/build/rpm.rb +0 -128
- data/dev/rpmtool +0 -21
- data/dev/test_rpm_packaging.sh +0 -28
- data/rpm/get_distro_id.py +0 -4
data/ext/nginx/ContentHandler.c
CHANGED
@@ -64,7 +64,7 @@ static FileType
|
|
64
64
|
get_file_type(const u_char *filename, unsigned int throttle_rate) {
|
65
65
|
struct stat buf;
|
66
66
|
int ret;
|
67
|
-
|
67
|
+
|
68
68
|
ret = pp_cached_file_stat_perform(pp_stat_cache,
|
69
69
|
(const char *) filename,
|
70
70
|
&buf,
|
@@ -118,14 +118,14 @@ map_uri_to_page_cache_file(ngx_http_request_t *r, ngx_str_t *public_dir,
|
|
118
118
|
ngx_str_t *page_cache_file)
|
119
119
|
{
|
120
120
|
u_char *end;
|
121
|
-
|
121
|
+
|
122
122
|
if ((r->method != NGX_HTTP_GET && r->method != NGX_HTTP_HEAD) || filename_len == 0) {
|
123
123
|
return 0;
|
124
124
|
}
|
125
|
-
|
125
|
+
|
126
126
|
/* From this point on we know that filename is not an empty string. */
|
127
|
-
|
128
|
-
|
127
|
+
|
128
|
+
|
129
129
|
/* Check whether `filename` is equal to public_dir.
|
130
130
|
* `filename` may also be equal to public_dir + "/" so check for that as well.
|
131
131
|
*/
|
@@ -133,30 +133,30 @@ map_uri_to_page_cache_file(ngx_http_request_t *r, ngx_str_t *public_dir,
|
|
133
133
|
/* If the URI maps to the 'public' or the alias directory (i.e. the request is the
|
134
134
|
* base URI) then index.html is the page cache file.
|
135
135
|
*/
|
136
|
-
|
136
|
+
|
137
137
|
if (filename_len + sizeof("/index.html") > page_cache_file->len) {
|
138
138
|
/* Page cache filename doesn't fit in the buffer. */
|
139
139
|
return 0;
|
140
140
|
}
|
141
|
-
|
141
|
+
|
142
142
|
end = ngx_copy(page_cache_file->data, filename, filename_len);
|
143
143
|
if (filename[filename_len - 1] != '/') {
|
144
144
|
end = ngx_copy(end, "/", 1);
|
145
145
|
}
|
146
146
|
end = ngx_copy(end, "index.html", sizeof("index.html"));
|
147
|
-
|
147
|
+
|
148
148
|
} else {
|
149
149
|
/* Otherwise, the page cache file is just filename + ".html". */
|
150
|
-
|
150
|
+
|
151
151
|
if (filename_len + sizeof(".html") > page_cache_file->len) {
|
152
152
|
/* Page cache filename doesn't fit in the buffer. */
|
153
153
|
return 0;
|
154
154
|
}
|
155
|
-
|
155
|
+
|
156
156
|
end = ngx_copy(page_cache_file->data, filename, filename_len);
|
157
157
|
end = ngx_copy(end, ".html", sizeof(".html"));
|
158
158
|
}
|
159
|
-
|
159
|
+
|
160
160
|
if (file_exists(page_cache_file->data, 0)) {
|
161
161
|
page_cache_file->len = end - page_cache_file->data - 1;
|
162
162
|
return 1;
|
@@ -171,7 +171,7 @@ find_base_uri(ngx_http_request_t *r, const passenger_loc_conf_t *loc,
|
|
171
171
|
{
|
172
172
|
ngx_uint_t i;
|
173
173
|
ngx_str_t *base_uris, *base_uri, *uri;
|
174
|
-
|
174
|
+
|
175
175
|
if (loc->base_uris == NGX_CONF_UNSET_PTR) {
|
176
176
|
return 0;
|
177
177
|
} else {
|
@@ -179,14 +179,14 @@ find_base_uri(ngx_http_request_t *r, const passenger_loc_conf_t *loc,
|
|
179
179
|
uri = &r->uri;
|
180
180
|
for (i = 0; i < loc->base_uris->nelts; i++) {
|
181
181
|
base_uri = &base_uris[i];
|
182
|
-
|
182
|
+
|
183
183
|
if (base_uri->len == 1 && base_uri->data[0] == '/') {
|
184
184
|
/* Ignore 'passenger_base_uri /' options. Users usually
|
185
185
|
* specify this out of ignorance.
|
186
186
|
*/
|
187
187
|
continue;
|
188
188
|
}
|
189
|
-
|
189
|
+
|
190
190
|
if (( uri->len == base_uri->len
|
191
191
|
&& ngx_strncmp(uri->data, base_uri->data, uri->len) == 0 )
|
192
192
|
|| ( uri->len > base_uri->len
|
@@ -207,7 +207,7 @@ set_upstream_server_address(ngx_http_upstream_t *upstream, ngx_http_upstream_con
|
|
207
207
|
const char *request_socket_filename;
|
208
208
|
unsigned int request_socket_filename_len;
|
209
209
|
struct sockaddr_un *sockaddr;
|
210
|
-
|
210
|
+
|
211
211
|
/* The Nginx API makes it extremely difficult to register an upstream server
|
212
212
|
* address outside of the configuration loading phase. However we don't know
|
213
213
|
* the helper agent's request socket filename until we're done with loading
|
@@ -221,7 +221,7 @@ set_upstream_server_address(ngx_http_upstream_t *upstream, ngx_http_upstream_con
|
|
221
221
|
request_socket_filename =
|
222
222
|
pp_agents_starter_get_request_socket_filename(pp_agents_starter,
|
223
223
|
&request_socket_filename_len);
|
224
|
-
|
224
|
+
|
225
225
|
address->name.data = (u_char *) request_socket_filename;
|
226
226
|
address->name.len = request_socket_filename_len;
|
227
227
|
strncpy(sockaddr->sun_path, request_socket_filename, sizeof(sockaddr->sun_path));
|
@@ -346,18 +346,18 @@ create_request(ngx_http_request_t *r)
|
|
346
346
|
passenger_loc_conf_t *slcf;
|
347
347
|
passenger_context_t *context;
|
348
348
|
ngx_http_script_len_code_pt lcode;
|
349
|
-
|
349
|
+
|
350
350
|
cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
|
351
351
|
slcf = ngx_http_get_module_loc_conf(r, ngx_http_passenger_module);
|
352
352
|
context = ngx_http_get_module_ctx(r, ngx_http_passenger_module);
|
353
353
|
if (context == NULL) {
|
354
354
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
355
355
|
}
|
356
|
-
|
356
|
+
|
357
357
|
app_type_string = (const u_char *) pp_get_app_type_name(context->app_type);
|
358
358
|
app_type_string_len = strlen((const char *) app_type_string) + 1; /* include null terminator */
|
359
|
-
|
360
|
-
|
359
|
+
|
360
|
+
|
361
361
|
/*
|
362
362
|
* Nginx unescapes URI's before passing them to Phusion Passenger,
|
363
363
|
* but backend processes expect the escaped version.
|
@@ -374,7 +374,7 @@ create_request(ngx_http_request_t *r)
|
|
374
374
|
/**************************************************
|
375
375
|
* Determine the request header length.
|
376
376
|
**************************************************/
|
377
|
-
|
377
|
+
|
378
378
|
len = 0;
|
379
379
|
|
380
380
|
/* Length of the Content-Length header. A value of -1 means that the content
|
@@ -384,7 +384,7 @@ create_request(ngx_http_request_t *r)
|
|
384
384
|
uint_to_str(r->headers_in.content_length_n, buf, sizeof(buf)) +
|
385
385
|
1; /* +1 for trailing null */
|
386
386
|
}
|
387
|
-
|
387
|
+
|
388
388
|
/* DOCUMENT_ROOT, SCRIPT_NAME, RAILS_RELATIVE_URL_ROOT, PATH_INFO and REQUEST_URI. */
|
389
389
|
len += sizeof("DOCUMENT_ROOT") + context->public_dir.len + 1;
|
390
390
|
if (context->base_uri.len > 0) {
|
@@ -400,7 +400,7 @@ create_request(ngx_http_request_t *r)
|
|
400
400
|
if (r->args.len > 0) {
|
401
401
|
len += 1 + r->args.len;
|
402
402
|
}
|
403
|
-
|
403
|
+
|
404
404
|
/* SERVER_NAME; must be equal to HTTP_HOST without the port part */
|
405
405
|
if (r->headers_in.host != NULL) {
|
406
406
|
tmp = memchr(r->headers_in.host->value.data, ':', r->headers_in.host->value.len);
|
@@ -413,19 +413,19 @@ create_request(ngx_http_request_t *r)
|
|
413
413
|
server_name_len = cscf->server_name.len;
|
414
414
|
}
|
415
415
|
len += sizeof("SERVER_NAME") + server_name_len + 1;
|
416
|
-
|
416
|
+
|
417
417
|
/* Various other HTTP headers. */
|
418
418
|
if (r->headers_in.content_type != NULL
|
419
419
|
&& r->headers_in.content_type->value.len > 0) {
|
420
420
|
len += sizeof("CONTENT_TYPE") + r->headers_in.content_type->value.len + 1;
|
421
421
|
}
|
422
|
-
|
422
|
+
|
423
423
|
#if (NGX_HTTP_SSL)
|
424
424
|
if (r->http_connection->ssl) {
|
425
425
|
len += sizeof("HTTPS") + sizeof("on");
|
426
426
|
}
|
427
427
|
#endif
|
428
|
-
|
428
|
+
|
429
429
|
/* Lengths of Passenger application pool options. */
|
430
430
|
len += slcf->options_cache.len;
|
431
431
|
|
@@ -433,7 +433,7 @@ create_request(ngx_http_request_t *r)
|
|
433
433
|
|
434
434
|
if (slcf->union_station_filters != NGX_CONF_UNSET_PTR && slcf->union_station_filters->nelts > 0) {
|
435
435
|
len += sizeof("UNION_STATION_FILTERS");
|
436
|
-
|
436
|
+
|
437
437
|
union_station_filters = (ngx_str_t *) slcf->union_station_filters->elts;
|
438
438
|
for (i = 0; i < slcf->union_station_filters->nelts; i++) {
|
439
439
|
if (i != 0) {
|
@@ -501,7 +501,7 @@ create_request(ngx_http_request_t *r)
|
|
501
501
|
/**************************************************
|
502
502
|
* Build the request header data.
|
503
503
|
**************************************************/
|
504
|
-
|
504
|
+
|
505
505
|
helper_agent_request_socket_password_data =
|
506
506
|
pp_agents_starter_get_request_socket_password(pp_agents_starter,
|
507
507
|
&helper_agent_request_socket_password_len);
|
@@ -521,7 +521,7 @@ create_request(ngx_http_request_t *r)
|
|
521
521
|
}
|
522
522
|
|
523
523
|
cl->buf = b;
|
524
|
-
|
524
|
+
|
525
525
|
/* Build SCGI header netstring length part. */
|
526
526
|
b->last = ngx_copy(b->last, helper_agent_request_socket_password_data,
|
527
527
|
helper_agent_request_socket_password_len);
|
@@ -537,22 +537,22 @@ create_request(ngx_http_request_t *r)
|
|
537
537
|
r->headers_in.content_length_n);
|
538
538
|
*b->last++ = (u_char) 0;
|
539
539
|
}
|
540
|
-
|
540
|
+
|
541
541
|
/* Build DOCUMENT_ROOT, SCRIPT_NAME, RAILS_RELATIVE_URL_ROOT, PATH_INFO and REQUEST_URI. */
|
542
542
|
b->last = ngx_copy(b->last, "DOCUMENT_ROOT", sizeof("DOCUMENT_ROOT"));
|
543
543
|
b->last = ngx_copy(b->last, context->public_dir.data,
|
544
544
|
context->public_dir.len + 1);
|
545
|
-
|
545
|
+
|
546
546
|
if (context->base_uri.len > 0) {
|
547
547
|
b->last = ngx_copy(b->last, "SCRIPT_NAME", sizeof("SCRIPT_NAME"));
|
548
548
|
b->last = ngx_copy(b->last, context->base_uri.data,
|
549
549
|
context->base_uri.len + 1);
|
550
|
-
|
550
|
+
|
551
551
|
b->last = ngx_copy(b->last, "RAILS_RELATIVE_URL_ROOT",
|
552
552
|
sizeof("RAILS_RELATIVE_URL_ROOT"));
|
553
553
|
b->last = ngx_copy(b->last, context->base_uri.data,
|
554
554
|
context->base_uri.len + 1);
|
555
|
-
|
555
|
+
|
556
556
|
b->last = ngx_copy(b->last, "PATH_INFO", sizeof("PATH_INFO"));
|
557
557
|
b->last = ngx_copy(b->last, escaped_uri.data + context->base_uri.len,
|
558
558
|
escaped_uri.len - context->base_uri.len);
|
@@ -560,12 +560,12 @@ create_request(ngx_http_request_t *r)
|
|
560
560
|
} else {
|
561
561
|
b->last = ngx_copy(b->last, "SCRIPT_NAME", sizeof("SCRIPT_NAME"));
|
562
562
|
b->last = ngx_copy(b->last, "", sizeof(""));
|
563
|
-
|
563
|
+
|
564
564
|
b->last = ngx_copy(b->last, "PATH_INFO", sizeof("PATH_INFO"));
|
565
565
|
b->last = ngx_copy(b->last, escaped_uri.data, escaped_uri.len);
|
566
566
|
b->last = ngx_copy(b->last, "", 1);
|
567
567
|
}
|
568
|
-
|
568
|
+
|
569
569
|
b->last = ngx_copy(b->last, "REQUEST_URI", sizeof("REQUEST_URI"));
|
570
570
|
b->last = ngx_copy(b->last, escaped_uri.data, escaped_uri.len);
|
571
571
|
if (r->args.len > 0) {
|
@@ -573,7 +573,7 @@ create_request(ngx_http_request_t *r)
|
|
573
573
|
b->last = ngx_copy(b->last, r->args.data, r->args.len);
|
574
574
|
}
|
575
575
|
b->last = ngx_copy(b->last, "", 1);
|
576
|
-
|
576
|
+
|
577
577
|
/* SERVER_NAME */
|
578
578
|
b->last = ngx_copy(b->last, "SERVER_NAME", sizeof("SERVER_NAME"));
|
579
579
|
if (r->headers_in.host != NULL) {
|
@@ -584,7 +584,7 @@ create_request(ngx_http_request_t *r)
|
|
584
584
|
server_name_len);
|
585
585
|
}
|
586
586
|
b->last = ngx_copy(b->last, "", 1);
|
587
|
-
|
587
|
+
|
588
588
|
/* Various other HTTP headers. */
|
589
589
|
if (r->headers_in.content_type != NULL
|
590
590
|
&& r->headers_in.content_type->value.len > 0) {
|
@@ -593,14 +593,14 @@ create_request(ngx_http_request_t *r)
|
|
593
593
|
r->headers_in.content_type->value.len);
|
594
594
|
b->last = ngx_copy(b->last, "", 1);
|
595
595
|
}
|
596
|
-
|
596
|
+
|
597
597
|
#if (NGX_HTTP_SSL)
|
598
598
|
if (r->http_connection->ssl) {
|
599
599
|
b->last = ngx_copy(b->last, "HTTPS", sizeof("HTTPS"));
|
600
600
|
b->last = ngx_copy(b->last, "on", sizeof("on"));
|
601
601
|
}
|
602
602
|
#endif
|
603
|
-
|
603
|
+
|
604
604
|
|
605
605
|
/* Build Passenger application pool option headers. */
|
606
606
|
b->last = ngx_copy(b->last, slcf->options_cache.data, slcf->options_cache.len);
|
@@ -612,7 +612,7 @@ create_request(ngx_http_request_t *r)
|
|
612
612
|
if (slcf->union_station_filters != NGX_CONF_UNSET_PTR && slcf->union_station_filters->nelts > 0) {
|
613
613
|
b->last = ngx_copy(b->last, "UNION_STATION_FILTERS",
|
614
614
|
sizeof("UNION_STATION_FILTERS"));
|
615
|
-
|
615
|
+
|
616
616
|
for (i = 0; i < slcf->union_station_filters->nelts; i++) {
|
617
617
|
if (i != 0) {
|
618
618
|
b->last = ngx_copy(b->last, "\1", 1);
|
@@ -700,7 +700,7 @@ create_request(ngx_http_request_t *r)
|
|
700
700
|
*b->last++ = (u_char) 0;
|
701
701
|
}
|
702
702
|
}
|
703
|
-
|
703
|
+
|
704
704
|
*b->last++ = (u_char) ',';
|
705
705
|
|
706
706
|
if (slcf->upstream_config.pass_request_body) {
|
@@ -1267,7 +1267,7 @@ passenger_content_handler(ngx_http_request_t *r)
|
|
1267
1267
|
if (!slcf->enabled) {
|
1268
1268
|
return NGX_DECLINED;
|
1269
1269
|
}
|
1270
|
-
|
1270
|
+
|
1271
1271
|
/* Let the next content handler take care of this request if this URL
|
1272
1272
|
* maps to an existing file.
|
1273
1273
|
*/
|
@@ -1275,7 +1275,7 @@ passenger_content_handler(ngx_http_request_t *r)
|
|
1275
1275
|
if (path_last != NULL && file_exists(path.data, 0)) {
|
1276
1276
|
return NGX_DECLINED;
|
1277
1277
|
}
|
1278
|
-
|
1278
|
+
|
1279
1279
|
/* Create a string containing the root path. This path already
|
1280
1280
|
* contains a trailing slash.
|
1281
1281
|
*/
|
@@ -1283,15 +1283,15 @@ passenger_content_handler(ngx_http_request_t *r)
|
|
1283
1283
|
*end = '\0';
|
1284
1284
|
root_path.data = root_path_str;
|
1285
1285
|
root_path.len = root_len;
|
1286
|
-
|
1287
|
-
|
1286
|
+
|
1287
|
+
|
1288
1288
|
context = ngx_pcalloc(r->pool, sizeof(passenger_context_t));
|
1289
1289
|
if (context == NULL) {
|
1290
1290
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
1291
1291
|
}
|
1292
1292
|
ngx_http_set_ctx(r, context, ngx_http_passenger_module);
|
1293
|
-
|
1294
|
-
|
1293
|
+
|
1294
|
+
|
1295
1295
|
/* Find the base URI for this web application, if any. */
|
1296
1296
|
if (find_base_uri(r, slcf, &base_uri)) {
|
1297
1297
|
/* Store the found base URI into context->public_dir. We infer that
|
@@ -1323,7 +1323,7 @@ passenger_content_handler(ngx_http_request_t *r)
|
|
1323
1323
|
*end = '\0';
|
1324
1324
|
context->public_dir.len = root_path.len;
|
1325
1325
|
}
|
1326
|
-
|
1326
|
+
|
1327
1327
|
/* If there's a corresponding page cache file for this URL, then serve that
|
1328
1328
|
* file instead.
|
1329
1329
|
*/
|
@@ -1333,7 +1333,7 @@ passenger_content_handler(ngx_http_request_t *r)
|
|
1333
1333
|
path_last - path.data, &page_cache_file)) {
|
1334
1334
|
return passenger_static_content_handler(r, &page_cache_file);
|
1335
1335
|
}
|
1336
|
-
|
1336
|
+
|
1337
1337
|
if (slcf->app_type.data == NULL) {
|
1338
1338
|
pp_error_init(&error);
|
1339
1339
|
if (slcf->app_root.data == NULL) {
|
@@ -1377,15 +1377,15 @@ passenger_content_handler(ngx_http_request_t *r)
|
|
1377
1377
|
return NGX_DECLINED;
|
1378
1378
|
}
|
1379
1379
|
}
|
1380
|
-
|
1381
|
-
|
1380
|
+
|
1381
|
+
|
1382
1382
|
/* Setup upstream stuff and prepare sending the request to the HelperAgent. */
|
1383
|
-
|
1383
|
+
|
1384
1384
|
if (ngx_http_upstream_create(r) != NGX_OK) {
|
1385
1385
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
1386
1386
|
}
|
1387
1387
|
u = r->upstream;
|
1388
|
-
|
1388
|
+
|
1389
1389
|
u->schema = pp_schema_string;
|
1390
1390
|
u->output.tag = (ngx_buf_tag_t) &ngx_http_passenger_module;
|
1391
1391
|
set_upstream_server_address(u, &slcf->upstream_config);
|
@@ -1402,7 +1402,7 @@ passenger_content_handler(ngx_http_request_t *r)
|
|
1402
1402
|
r->state = 0;
|
1403
1403
|
|
1404
1404
|
u->buffering = slcf->upstream_config.buffering;
|
1405
|
-
|
1405
|
+
|
1406
1406
|
u->pipe = ngx_pcalloc(r->pool, sizeof(ngx_event_pipe_t));
|
1407
1407
|
if (u->pipe == NULL) {
|
1408
1408
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
data/ext/nginx/ContentHandler.h
CHANGED
@@ -39,13 +39,13 @@ typedef struct {
|
|
39
39
|
ngx_uint_t status_count;
|
40
40
|
u_char *status_start;
|
41
41
|
u_char *status_end;
|
42
|
-
|
42
|
+
|
43
43
|
/** The application's 'public' directory. */
|
44
44
|
ngx_str_t public_dir;
|
45
|
-
|
45
|
+
|
46
46
|
/** The application's base URI. Points to an empty string if none. */
|
47
47
|
ngx_str_t base_uri;
|
48
|
-
|
48
|
+
|
49
49
|
/** The application's type. */
|
50
50
|
PassengerAppType app_type;
|
51
51
|
} passenger_context_t;
|
@@ -30,7 +30,7 @@
|
|
30
30
|
static void
|
31
31
|
set_request_extension(ngx_http_request_t *r, ngx_str_t *filename) {
|
32
32
|
u_char *tmp;
|
33
|
-
|
33
|
+
|
34
34
|
/* Scan filename from the right until we've found a slash or a dot. */
|
35
35
|
tmp = filename->data + filename->len - 1;
|
36
36
|
while (tmp >= filename->data && *tmp != '/' && *tmp != '.') {
|
@@ -124,7 +124,7 @@ passenger_static_content_handler(ngx_http_request_t *r, ngx_str_t *filename)
|
|
124
124
|
#if NGINX_VERSION_NUM >= 7000
|
125
125
|
r->root_tested = !r->error_page;
|
126
126
|
#endif
|
127
|
-
|
127
|
+
|
128
128
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0, "http static fd: %d", of.fd);
|
129
129
|
|
130
130
|
if (of.is_dir) {
|
@@ -67,7 +67,7 @@ ngx_cycle_t *pp_current_cycle;
|
|
67
67
|
data to the upstream handler even though it shouldn't. Is this an Nginx
|
68
68
|
bug? In any case, setting ngx_http_core_loc_conf_t->handler fixed the
|
69
69
|
problem.
|
70
|
-
|
70
|
+
|
71
71
|
static ngx_int_t
|
72
72
|
register_content_handler(ngx_conf_t *cf)
|
73
73
|
{
|
@@ -81,7 +81,7 @@ register_content_handler(ngx_conf_t *cf)
|
|
81
81
|
return NGX_ERROR;
|
82
82
|
}
|
83
83
|
*h = passenger_content_handler;
|
84
|
-
|
84
|
+
|
85
85
|
return NGX_OK;
|
86
86
|
}
|
87
87
|
*/
|
@@ -89,7 +89,7 @@ register_content_handler(ngx_conf_t *cf)
|
|
89
89
|
static void
|
90
90
|
ignore_sigpipe() {
|
91
91
|
struct sigaction action;
|
92
|
-
|
92
|
+
|
93
93
|
action.sa_handler = SIG_IGN;
|
94
94
|
action.sa_flags = 0;
|
95
95
|
sigemptyset(&action.sa_mask);
|
@@ -127,11 +127,11 @@ save_master_process_pid(ngx_cycle_t *cycle) {
|
|
127
127
|
u_char filename[NGX_MAX_PATH];
|
128
128
|
u_char *last;
|
129
129
|
FILE *f;
|
130
|
-
|
130
|
+
|
131
131
|
last = ngx_snprintf(filename, sizeof(filename) - 1, "%s/control_process.pid",
|
132
132
|
pp_agents_starter_get_server_instance_dir(pp_agents_starter));
|
133
133
|
*last = (u_char) '\0';
|
134
|
-
|
134
|
+
|
135
135
|
f = fopen((const char *) filename, "w");
|
136
136
|
if (f != NULL) {
|
137
137
|
fprintf(f, "%ld", (long) getppid());
|
@@ -140,7 +140,7 @@ save_master_process_pid(ngx_cycle_t *cycle) {
|
|
140
140
|
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
141
141
|
"could not create %s", filename);
|
142
142
|
}
|
143
|
-
|
143
|
+
|
144
144
|
return NGX_OK;
|
145
145
|
}
|
146
146
|
|
@@ -156,7 +156,7 @@ starting_helper_server_after_fork(void *arg) {
|
|
156
156
|
ngx_uint_t i;
|
157
157
|
ngx_str_t *envs;
|
158
158
|
const char *env;
|
159
|
-
|
159
|
+
|
160
160
|
/* At this point, stdout and stderr may still point to the console.
|
161
161
|
* Make sure that they're both redirected to the log file.
|
162
162
|
*/
|
@@ -201,7 +201,7 @@ starting_helper_server_after_fork(void *arg) {
|
|
201
201
|
putenv(strdup(env));
|
202
202
|
}
|
203
203
|
}
|
204
|
-
|
204
|
+
|
205
205
|
/* Set SERVER_SOFTWARE so that application processes know what web
|
206
206
|
* server they're running on during startup. */
|
207
207
|
setenv("SERVER_SOFTWARE", NGINX_VER, 1);
|
@@ -254,12 +254,12 @@ start_watchdog(ngx_cycle_t *cycle) {
|
|
254
254
|
u_char filename[NGX_MAX_PATH], *last;
|
255
255
|
char *passenger_root = NULL;
|
256
256
|
char *error_message = NULL;
|
257
|
-
|
257
|
+
|
258
258
|
core_conf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
|
259
259
|
result = NGX_OK;
|
260
260
|
params = pp_variant_map_new();
|
261
261
|
passenger_root = ngx_str_null_terminate(&passenger_main_conf.root_dir);
|
262
|
-
|
262
|
+
|
263
263
|
prestart_uris = (ngx_str_t *) passenger_main_conf.prestart_uris->elts;
|
264
264
|
prestart_uris_ary = calloc(sizeof(char *), passenger_main_conf.prestart_uris->nelts);
|
265
265
|
for (i = 0; i < passenger_main_conf.prestart_uris->nelts; i++) {
|
@@ -299,7 +299,7 @@ start_watchdog(ngx_cycle_t *cycle) {
|
|
299
299
|
(const char *) ctl[i].key.data, ctl[i].key.len - 1,
|
300
300
|
(const char *) ctl[i].value.data, ctl[i].value.len - 1);
|
301
301
|
}
|
302
|
-
|
302
|
+
|
303
303
|
ret = pp_agents_starter_start(pp_agents_starter,
|
304
304
|
passenger_root,
|
305
305
|
params,
|
@@ -311,7 +311,7 @@ start_watchdog(ngx_cycle_t *cycle) {
|
|
311
311
|
result = NGX_ERROR;
|
312
312
|
goto cleanup;
|
313
313
|
}
|
314
|
-
|
314
|
+
|
315
315
|
/* Create the file passenger_temp_dir + "/control_process.pid"
|
316
316
|
* and make it writable by the worker processes. This is because
|
317
317
|
* save_master_process_pid is run after Nginx has lowered privileges.
|
@@ -350,7 +350,7 @@ start_watchdog(ngx_cycle_t *cycle) {
|
|
350
350
|
result = NGX_ERROR;
|
351
351
|
goto cleanup;
|
352
352
|
}
|
353
|
-
|
353
|
+
|
354
354
|
cleanup:
|
355
355
|
pp_variant_map_free(params);
|
356
356
|
free(passenger_root);
|
@@ -361,11 +361,11 @@ cleanup:
|
|
361
361
|
}
|
362
362
|
free(prestart_uris_ary);
|
363
363
|
}
|
364
|
-
|
364
|
+
|
365
365
|
if (result == NGX_ERROR && passenger_main_conf.abort_on_startup_error) {
|
366
366
|
exit(1);
|
367
367
|
}
|
368
|
-
|
368
|
+
|
369
369
|
return result;
|
370
370
|
}
|
371
371
|
|
@@ -390,9 +390,9 @@ static ngx_int_t
|
|
390
390
|
pre_config_init(ngx_conf_t *cf)
|
391
391
|
{
|
392
392
|
char *error_message;
|
393
|
-
|
393
|
+
|
394
394
|
shutdown_helper_server();
|
395
|
-
|
395
|
+
|
396
396
|
ngx_memzero(&passenger_main_conf, sizeof(passenger_main_conf_t));
|
397
397
|
pp_schema_string.data = (u_char *) "passenger:";
|
398
398
|
pp_schema_string.len = sizeof("passenger:") - 1;
|
@@ -401,13 +401,13 @@ pre_config_init(ngx_conf_t *cf)
|
|
401
401
|
pp_stat_cache = pp_cached_file_stat_new(1024);
|
402
402
|
pp_app_type_detector = pp_app_type_detector_new();
|
403
403
|
pp_agents_starter = pp_agents_starter_new(AS_NGINX, &error_message);
|
404
|
-
|
404
|
+
|
405
405
|
if (pp_agents_starter == NULL) {
|
406
406
|
ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno, "%s", error_message);
|
407
407
|
free(error_message);
|
408
408
|
return NGX_ERROR;
|
409
409
|
}
|
410
|
-
|
410
|
+
|
411
411
|
return NGX_OK;
|
412
412
|
}
|
413
413
|
|
@@ -447,10 +447,10 @@ init_module(ngx_cycle_t *cycle) {
|
|
447
447
|
static ngx_int_t
|
448
448
|
init_worker_process(ngx_cycle_t *cycle) {
|
449
449
|
ngx_core_conf_t *core_conf;
|
450
|
-
|
450
|
+
|
451
451
|
if (passenger_main_conf.root_dir.len != 0) {
|
452
452
|
save_master_process_pid(cycle);
|
453
|
-
|
453
|
+
|
454
454
|
core_conf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
|
455
455
|
if (core_conf->master) {
|
456
456
|
pp_agents_starter_detach(pp_agents_starter);
|