Compare commits

...

32 Commits

Author SHA1 Message Date
Otto van der Schaaf 26a0c37b97 location-header: Only set the location field when the input
Only set headers_out.location when the input also originally did
that.

This still needs a test to prevent regression, but I thought I'd
put this out so people can try this.

Should fix https://github.com/pagespeed/ngx_pagespeed/issues/819
Might help https://github.com/pagespeed/ngx_pagespeed/issues/711
2014-10-21 07:43:04 +02:00
Otto van der Schaaf ccd800a0b1 Merge pull request #818 from pagespeed/oschaaf-fix-stdio-logging
logging: init logging early, hand ProxyFetchFactory correct server log
2014-10-16 15:58:57 +02:00
Otto van der Schaaf e2e21474ce logging: init logging early, hand ProxyFetchFactory correct server log
- Prevent logging to stdout/stderr, make sure we log to error.log for
early messages during initialization. Note that nginx is still working
to setup its logging configuration, so these early messages will go
through its defaults. Which means that only warnings or worse will pass
for early logging messages.
- Make sure we init ProxyFetchFactories's NgxMessageHandler to the correct
server{} specific log so it will write to the error_log configured
in the server{} block instead of the global error_log.

Fixes https://github.com/pagespeed/ngx_pagespeed/issues/808
Helps https://github.com/pagespeed/ngx_pagespeed/issues/817
2014-10-01 11:09:20 +02:00
Otto van der Schaaf 7680a159a7 Merge pull request #814 from pagespeed/oschaaf-gcc-4.1.2-segfault
gcc-4.1.2-segfault: Make sure we init all ps_request_ctx_t members
2014-09-26 16:23:30 +02:00
Otto van der Schaaf 7aa5bc4a99 gcc-4.1.2-segfault: Make sure we init all ps_request_ctx_t members
When built with gcc-4.1.2, this change prevents segmentation faults
caused by undefined behaviour via uninitialized members.

Fixes https://github.com/pagespeed/ngx_pagespeed/issues/813
2014-09-26 00:17:11 +02:00
Jeffrey Crowell 462acc9eee update version number in the config file 2014-09-17 11:10:56 -04:00
Jeffrey Crowell 4678a62be8 Fix config file based on trunk-tracking instead of master 2014-09-17 11:05:55 -04:00
Jeffrey Crowell 525e331c0c Fix config file
Config was improperly merged from master, fixing.
2014-09-17 10:26:11 -04:00
Otto van der Schaaf dc40c902ec connection_read_handler: fix potential double free
In connection_read_handler(), make sure we act accordingly when
r->connection->error is set (indicating the the current request has
been finalized).

Reproduction of what happens when we don't: enable IPRO+SPDY, and
rapidly refresh a page with chrome. These rapid abortions will
eventually trigger a segfault/hang/misc bad behaviour.
2014-09-15 10:37:42 -04:00
Otto van der Schaaf 6a8a1c5bf7 IPRO: Fix a race in processing writes() from NgxBaseFetch
For FetchInPlaceResource, NgxBaseFetch would send two bytes down its
pipe, one upon HeaderComplete() and one upon HandleDone(). We need
only one to resume processing on the nginx side.

There is a race between ps_connection_read_handler() and processing
of the byte send by NgxBaseFetch::HandleDone().
ps_connection_read_handler() clears the pipe when the request is
finalized, and also drains it on each event - so two writes could be
processed as one when lucky, masking the problem).

One concrete problem this solved for me was that SPDY + IPRO +
proxy_pass would segfault, hang, and/or pass on 5xx/404 responses
from IPRO lookup fetches to the browser, next to alerts about
r->count being zero in nginx's error.log

Might fix https://github.com/pagespeed/ngx_pagespeed/issues/788
Fixes https://github.com/pagespeed/ngx_pagespeed/issues/792
2014-09-12 10:59:16 -04:00
Jeffrey Crowell 5bcd9e277e release: version 1.8.31.4 -> 1.9.32.1 2014-09-11 13:47:00 -04:00
Jeffrey Crowell 554577bbf2 Merge branch 'master' into HEAD
Preparing for 1.9.32.1 release

Conflicts:
	config
	src/ngx_pagespeed.cc
	src/ngx_rewrite_driver_factory.h
	src/ngx_rewrite_options.cc
	test/nginx_system_test.sh
	test/pagespeed_test.conf.template
2014-09-11 13:45:22 -04:00
Jeffrey Crowell 458a2f5236 Merge pull request #789 from gmszone/patch-1
Update config
2014-09-03 09:59:38 -04:00
Phodal Huang 71e89efc64 Update config 2014-09-02 13:49:49 +08:00
Otto van der Schaaf bbdfb5b429 Merge pull request #744 from pagespeed/oschaaf-double-location
location-header: tweak location header handling
2014-07-16 00:50:25 +02:00
Otto van der Schaaf 1f02f368e1 location-header: tweak location header handling
- Fix potentially sending the location header into PSOL twice.
- Be more thorough when unsetting the location header

Attempts to fix https://github.com/pagespeed/ngx_pagespeed/issues/725
2014-06-30 00:54:58 +02:00
Otto van der Schaaf 0c1cbbdf64 Merge pull request #736 from pagespeed/oschaaf-lff-script-support
script-variables: Support LoadFromFileXXX
2014-06-28 00:01:03 +02:00
Otto van der Schaaf 75a4481750 script-variables: Support LoadFromFileXXX
Add support for script variables in LoadFromFileXXX configuration,
which can be enabled by adding "pagespeed ProcessScriptVariables on" in
the http{} block.

Note that tests currently can't pass because of a failing unrelated test:
"start_test PageSpeed CSS loaded in fallback mode is always chunked"
I have tested this by commenting that test, but re-enabled the test before
making the pull to keep the diff clean.

Fixes https://github.com/pagespeed/ngx_pagespeed/issues/549
Docs: https://github.com/pagespeed/ngx_pagespeed/wiki/Script-variables-in-LoadFromFile-configuration
2014-06-27 23:55:34 +02:00
Jeff Kaufman b1e188bdb6 readme: reference doc on developers.google.com instead of duplicating it.
Conflicts:
	README.md
2014-06-23 10:41:47 -04:00
Jan-Willem Maessen 4d940fb84e Update for 1.8.31.4 2014-06-17 13:32:51 -04:00
Jan-Willem Maessen a6a2da765b Merge remote-tracking branch 'origin/release-1.8.31.3-beta'
Pulling in upstream merge to local master.
2014-05-29 15:06:03 -04:00
Jan-Willem Maessen 70038bc64a Merge pull request #714 from pagespeed/jmaessen-prepare-release-1.8.31.3-beta
Jmaessen prepare release 1.8.31.3 beta
2014-05-29 15:01:45 -04:00
Jan-Willem Maessen 815fa29985 Clarify test name and test comment. 2014-05-29 14:51:36 -04:00
Jan-Willem Maessen c82bb2c7a4 Version 1.8.31.2 -> 1.8.31.3 2014-05-29 14:32:18 -04:00
Jan-Willem Maessen e9eaa23356 Test fixups because fallback css now always uses chunked encoding in 1.8.31.3 2014-05-29 14:30:03 -04:00
Jeff Kaufman 168df6ae68 readme: with 1.8 we need different default config 2014-05-28 16:34:12 -04:00
Jan-Willem Maessen a7969a6382 Merge pull request #710 from pagespeed/jefftk-unbackport-roo-test
fixup: unbackport the RequestOptionOverride tests from 8246c03f
2014-05-28 11:17:06 -04:00
Jeff Kaufman 243d4e1931 fixup: unbackport the RequestOptionOverride tests from 8246c03f 2014-05-28 11:14:14 -04:00
Jeff Kaufman 8246c03fda options: support StaticAssetPrefix
Backporting this to master for 1.8.31.3.

Fixes #705.
2014-05-27 11:47:36 -04:00
Jeff Kaufman 99ac026f00 readme: 1.4.6 -> 1.6.0 2014-05-12 10:02:19 -04:00
Jeff Kaufman 90e4c40d86 Allow admin paths to be set at server scope. 2014-05-12 09:35:54 -04:00
Jan-Willem Maessen 0de4e20be1 release: version 1.7.30.4 -> 1.8.31.2 2014-05-09 11:28:04 -04:00
7 changed files with 113 additions and 54 deletions
+27 -27
View File
@@ -27,8 +27,8 @@ if [ "$mod_pagespeed_dir" = "unset" ] ; then
echo " You need to separately download the pagespeed library:" echo " You need to separately download the pagespeed library:"
echo "" echo ""
echo " $ cd /path/to/ngx_pagespeed" echo " $ cd /path/to/ngx_pagespeed"
echo " $ wget https://dl.google.com/dl/page-speed/psol/1.8.31.2.tar.gz" echo " $ wget https://dl.google.com/dl/page-speed/psol/1.9.32.1.tar.gz"
echo " $ tar -xzvf 1.8.31.2.tar.gz # expands to psol/" echo " $ tar -xzvf 1.9.32.1.tar.gz # expands to psol/"
echo "" echo ""
echo " Or see the installation instructions:" echo " Or see the installation instructions:"
echo " https://github.com/pagespeed/ngx_pagespeed#how-to-build" echo " https://github.com/pagespeed/ngx_pagespeed#how-to-build"
@@ -39,31 +39,6 @@ else
build_from_source=true build_from_source=true
fi fi
psol_binary="${PSOL_BINARY:-unset}"
if [ "$psol_binary" = "unset" ] ; then
if $build_from_source ; then
psol_binary="\
$mod_pagespeed_dir/net/instaweb/automatic/pagespeed_automatic.a"
else
psol_library_dir="$ngx_addon_dir/psol/lib/$buildtype/$os_name/$arch_name"
psol_binary="$psol_library_dir/pagespeed_automatic.a"
fi
fi
echo "mod_pagespeed_dir=$mod_pagespeed_dir"
echo "build_from_source=$build_from_source"
ngx_feature="psol"
ngx_feature_name=""
ngx_feature_run=no
ngx_feature_incs="
#include \"net/instaweb/htmlparse/public/html_parse.h\"
#include \"net/instaweb/htmlparse/public/html_writer_filter.h\"
#include \"net/instaweb/util/public/string.h\"
#include \"net/instaweb/util/public/string_writer.h\"
#include \"net/instaweb/util/public/null_message_handler.h\"
"
os_name='unknown_os' os_name='unknown_os'
arch_name='unknown_arch' arch_name='unknown_arch'
uname_os=`uname` uname_os=`uname`
@@ -124,6 +99,31 @@ if [ "$WNO_ERROR" = "YES" ]; then
CFLAGS="$CFLAGS -Wno-error" CFLAGS="$CFLAGS -Wno-error"
fi fi
psol_binary="${PSOL_BINARY:-unset}"
if [ "$psol_binary" = "unset" ] ; then
if $build_from_source ; then
psol_binary="\
$mod_pagespeed_dir/net/instaweb/automatic/pagespeed_automatic.a"
else
psol_library_dir="$ngx_addon_dir/psol/lib/$buildtype/$os_name/$arch_name"
psol_binary="$psol_library_dir/pagespeed_automatic.a"
fi
fi
echo "mod_pagespeed_dir=$mod_pagespeed_dir"
echo "build_from_source=$build_from_source"
ngx_feature="psol"
ngx_feature_name=""
ngx_feature_run=no
ngx_feature_incs="
#include \"pagespeed/kernel/base/string.h\"
#include \"pagespeed/kernel/base/string_writer.h\"
#include \"pagespeed/kernel/base/null_message_handler.h\"
#include \"pagespeed/kernel/html/html_parse.h\"
#include \"pagespeed/kernel/html/html_writer_filter.h\"
"
pagespeed_include="\ pagespeed_include="\
$mod_pagespeed_dir \ $mod_pagespeed_dir \
$mod_pagespeed_dir/third_party/chromium/src \ $mod_pagespeed_dir/third_party/chromium/src \
+9 -3
View File
@@ -39,7 +39,7 @@ NgxBaseFetch::NgxBaseFetch(ngx_http_request_t* r, int pipe_fd,
last_buf_sent_(false), last_buf_sent_(false),
pipe_fd_(pipe_fd), pipe_fd_(pipe_fd),
references_(2), references_(2),
handle_error_(true), ipro_lookup_(false),
preserve_caching_headers_(preserve_caching_headers) { preserve_caching_headers_(preserve_caching_headers) {
if (pthread_mutex_init(&mutex_, NULL)) CHECK(0); if (pthread_mutex_init(&mutex_, NULL)) CHECK(0);
} }
@@ -137,14 +137,20 @@ void NgxBaseFetch::HandleHeadersComplete() {
int status_code = response_headers()->status_code(); int status_code = response_headers()->status_code();
bool status_ok = (status_code != 0) && (status_code < 400); bool status_ok = (status_code != 0) && (status_code < 400);
if (status_ok || handle_error_) { if (!ipro_lookup_ || status_ok) {
// If this is a 404 response we need to count it in the stats. // If this is a 404 response we need to count it in the stats.
if (response_headers()->status_code() == HttpStatus::kNotFound) { if (response_headers()->status_code() == HttpStatus::kNotFound) {
server_context_->rewrite_stats()->resource_404_count()->Add(1); server_context_->rewrite_stats()->resource_404_count()->Add(1);
} }
} }
RequestCollection(); // Headers available. // For the IPRO lookup, supress notification of the nginx side here.
// If we send both this event and the one from done, nasty stuff will happen
// if we loose the race with with the nginx side destructing this base fetch
// instance (and thereby clearing the byte and its pending extraneous event.
if (!ipro_lookup_) {
RequestCollection(); // Headers available.
}
} }
bool NgxBaseFetch::HandleFlush(MessageHandler* handler) { bool NgxBaseFetch::HandleFlush(MessageHandler* handler) {
+2 -2
View File
@@ -79,7 +79,7 @@ class NgxBaseFetch : public AsyncFetch {
// Called by nginx when it's done with us. // Called by nginx when it's done with us.
void Release(); void Release();
void set_handle_error(bool x) { handle_error_ = x; } void set_ipro_lookup(bool x) { ipro_lookup_ = x; }
private: private:
virtual bool HandleWrite(const StringPiece& sp, MessageHandler* handler); virtual bool HandleWrite(const StringPiece& sp, MessageHandler* handler);
@@ -117,7 +117,7 @@ class NgxBaseFetch : public AsyncFetch {
// decremented once when Done() is called and once when Release() is called. // decremented once when Done() is called and once when Release() is called.
int references_; int references_;
pthread_mutex_t mutex_; pthread_mutex_t mutex_;
bool handle_error_; bool ipro_lookup_;
PreserveCachingHeaders preserve_caching_headers_; PreserveCachingHeaders preserve_caching_headers_;
DISALLOW_COPY_AND_ASSIGN(NgxBaseFetch); DISALLOW_COPY_AND_ASSIGN(NgxBaseFetch);
+69 -22
View File
@@ -89,6 +89,8 @@ extern ngx_module_t ngx_pagespeed;
namespace net_instaweb { namespace net_instaweb {
const char* kInternalEtagName = "@psol-etag"; const char* kInternalEtagName = "@psol-etag";
bool factory_init_called = false;
// The process context takes care of proactively initialising // The process context takes care of proactively initialising
// a few libraries for us, some of which are not thread-safe // a few libraries for us, some of which are not thread-safe
// when they are initialized lazily. // when they are initialized lazily.
@@ -206,6 +208,13 @@ ngx_int_t string_piece_to_buffer_chain(
namespace { namespace {
// Get the context for this request. ps_connection_read_handler should already
// have been called to create it.
ps_request_ctx_t* ps_get_request_context(ngx_http_request_t* r) {
return static_cast<ps_request_ctx_t*>(
ngx_http_get_module_ctx(r, ngx_pagespeed));
}
// Setting headers in nginx is tricky because it's not just a matter of adding // Setting headers in nginx is tricky because it's not just a matter of adding
// them to a list. You also need to remove them if there's already one there, // them to a list. You also need to remove them if there's already one there,
// as well as setting the shortcut pointers (both upper case and lower case). // as well as setting the shortcut pointers (both upper case and lower case).
@@ -286,11 +295,6 @@ void copy_response_headers_from_ngx(const ngx_http_request_t* r,
headers->set_status_code(r->headers_out.status); headers->set_status_code(r->headers_out.status);
if (r->headers_out.location != NULL) {
headers->Add(HttpAttributes::kLocation,
str_to_string_piece(r->headers_out.location->value));
}
// Manually copy over the content type because it's not included in // Manually copy over the content type because it's not included in
// request_->headers_out.headers. // request_->headers_out.headers.
headers->Add(HttpAttributes::kContentType, headers->Add(HttpAttributes::kContentType,
@@ -435,7 +439,10 @@ ngx_int_t copy_response_headers_to_ngx(
} else if (STR_EQ_LITERAL(name, "Last-Modified")) { } else if (STR_EQ_LITERAL(name, "Last-Modified")) {
headers_out->last_modified = header; headers_out->last_modified = header;
} else if (STR_EQ_LITERAL(name, "Location")) { } else if (STR_EQ_LITERAL(name, "Location")) {
headers_out->location = header; ps_request_ctx_t* ctx = ps_get_request_context(r);
if (ctx->location_field_set) {
headers_out->location = header;
}
} else if (STR_EQ_LITERAL(name, "Server")) { } else if (STR_EQ_LITERAL(name, "Server")) {
headers_out->server = header; headers_out->server = header;
} else if (STR_EQ_LITERAL(name, "Content-Length")) { } else if (STR_EQ_LITERAL(name, "Content-Length")) {
@@ -610,6 +617,16 @@ char* ps_configure(ngx_conf_t* cf,
NgxRewriteOptions** options, NgxRewriteOptions** options,
MessageHandler* handler, MessageHandler* handler,
net_instaweb::RewriteOptions::OptionScope option_scope) { net_instaweb::RewriteOptions::OptionScope option_scope) {
ps_main_conf_t* cfg_m = static_cast<ps_main_conf_t*>(
ngx_http_conf_get_module_main_conf(cf, ngx_pagespeed));
if (!factory_init_called) {
// Init logging to nginx's default error_log.
cfg_m->driver_factory->LoggingInit(cf->cycle->log);
cfg_m->driver_factory->Init();
factory_init_called = true;
}
// args[0] is always "pagespeed"; ignore it. // args[0] is always "pagespeed"; ignore it.
ngx_uint_t n_args = cf->args->nelts - 1; ngx_uint_t n_args = cf->args->nelts - 1;
@@ -660,8 +677,6 @@ char* ps_configure(ngx_conf_t* cf,
// directive yet. That happens below in ParseAndSetOptions(). // directive yet. That happens below in ParseAndSetOptions().
} }
ps_main_conf_t* cfg_m = static_cast<ps_main_conf_t*>(
ngx_http_cycle_get_module_main_conf(cf->cycle, ngx_pagespeed));
if (*options == NULL) { if (*options == NULL) {
*options = new NgxRewriteOptions( *options = new NgxRewriteOptions(
cfg_m->driver_factory->thread_system()); cfg_m->driver_factory->thread_system());
@@ -730,7 +745,16 @@ void ps_cleanup_srv_conf(void* data) {
// from being executed // from being executed
if (!factory_deleted && cfg_s->server_context != NULL) { if (!factory_deleted && cfg_s->server_context != NULL) {
delete cfg_s->server_context->factory(); NgxRewriteDriverFactory* factory = dynamic_cast<NgxRewriteDriverFactory*>(
cfg_s->server_context->factory());
if (!factory_init_called) {
factory->LoggingInit(ngx_cycle->log);
factory->Init();
factory_init_called = true;
}
delete factory;
factory_deleted = true; factory_deleted = true;
} }
if (cfg_s->proxy_fetch_factory != NULL) { if (cfg_s->proxy_fetch_factory != NULL) {
@@ -800,7 +824,7 @@ void* ps_create_main_conf(ngx_conf_t* cf) {
new SystemThreadSystem(), new SystemThreadSystem(),
"" /* hostname, not used */, "" /* hostname, not used */,
-1 /* port, not used */); -1 /* port, not used */);
cfg_m->driver_factory->Init(); factory_init_called = false;
ps_set_conf_cleanup_handler(cf, ps_cleanup_main_conf, cfg_m); ps_set_conf_cleanup_handler(cf, ps_cleanup_main_conf, cfg_m);
return cfg_m; return cfg_m;
} }
@@ -1084,13 +1108,6 @@ GoogleString ps_determine_url(ngx_http_request_t* r) {
host, port_string, str_to_string_piece(r->unparsed_uri)); host, port_string, str_to_string_piece(r->unparsed_uri));
} }
// Get the context for this request. ps_connection_read_handler should already
// have been called to create it.
ps_request_ctx_t* ps_get_request_context(ngx_http_request_t* r) {
return static_cast<ps_request_ctx_t*>(
ngx_http_get_module_ctx(r, ngx_pagespeed));
}
void ps_release_base_fetch(ps_request_ctx_t* ctx); void ps_release_base_fetch(ps_request_ctx_t* ctx);
// we are still at pagespeed phase // we are still at pagespeed phase
@@ -1178,6 +1195,12 @@ ngx_int_t ps_base_fetch_handler(ngx_http_request_t* r) {
STR_CASE_EQ_LITERAL(header->key, "Last-Modified") || STR_CASE_EQ_LITERAL(header->key, "Last-Modified") ||
STR_CASE_EQ_LITERAL(header->key, "Expires"))))) { STR_CASE_EQ_LITERAL(header->key, "Expires"))))) {
header->hash = 0; header->hash = 0;
if (STR_CASE_EQ_LITERAL(header->key, "Location")) {
// There's a possible issue with the location header, where setting
// the hash to 0 is not enough. See:
// https://github.com/nginx/nginx/blob/master/src/http/ngx_http_header_filter_module.c#L314
r->headers_out.location = NULL;
}
} }
} }
} else { } else {
@@ -1280,6 +1303,15 @@ void ps_connection_read_handler(ngx_event_t* ev) {
rc = read(c->fd, chr, 256); rc = read(c->fd, chr, 256);
} while (rc > 0 || (rc == -1 && errno == EINTR)); // Retry on EINTR. } while (rc > 0 || (rc == -1 && errno == EINTR)); // Retry on EINTR.
if (r->connection->error) {
ngx_log_error(NGX_LOG_DEBUG, ngx_cycle->log, 0,
"pagespeed [%p] request already finalized", r);
ctx->pagespeed_connection = NULL;
ngx_close_connection(c);
ngx_http_finalize_request(r, NGX_ERROR);
return;
}
if (rc == -1 && errno != EAGAIN && errno != EWOULDBLOCK) { if (rc == -1 && errno != EAGAIN && errno != EWOULDBLOCK) {
ctx->pagespeed_connection = NULL; ctx->pagespeed_connection = NULL;
ngx_close_connection(c); ngx_close_connection(c);
@@ -1844,12 +1876,20 @@ ngx_int_t ps_resource_handler(ngx_http_request_t* r,
CHECK(ctx == NULL); CHECK(ctx == NULL);
ctx = new ps_request_ctx_t(); ctx = new ps_request_ctx_t();
ctx->base_fetch = NULL;
ctx->pagespeed_connection = NULL;
ctx->r = r; ctx->r = r;
ctx->write_pending = false;
ctx->html_rewrite = false; ctx->html_rewrite = false;
ctx->in_place = false; ctx->in_place = false;
ctx->pagespeed_connection = NULL; ctx->write_pending = false;
ctx->fetch_done = false;
ctx->preserve_caching_headers = kDontPreserveHeaders; ctx->preserve_caching_headers = kDontPreserveHeaders;
ctx->proxy_fetch = NULL;
ctx->inflater_ = NULL;
ctx->driver = NULL;
ctx->recorder = NULL;
ctx->ipro_response_headers = NULL;
ctx->location_field_set = false;
// See build_context_for_request() in mod_instaweb.cc // See build_context_for_request() in mod_instaweb.cc
// TODO(jefftk): Is this the right place to be modifying caching headers for // TODO(jefftk): Is this the right place to be modifying caching headers for
@@ -2023,7 +2063,7 @@ ngx_int_t ps_resource_handler(ngx_http_request_t* r,
url_string.c_str()); url_string.c_str());
ctx->in_place = true; ctx->in_place = true;
ctx->base_fetch->set_handle_error(false); ctx->base_fetch->set_ipro_lookup(true);
ctx->driver->FetchInPlaceResource( ctx->driver->FetchInPlaceResource(
url, false /* proxy_mode */, ctx->base_fetch); url, false /* proxy_mode */, ctx->base_fetch);
@@ -2263,6 +2303,8 @@ ngx_int_t ps_html_rewrite_header_filter(ngx_http_request_t* r) {
} }
ps_strip_html_headers(r); ps_strip_html_headers(r);
// See https://github.com/pagespeed/ngx_pagespeed/issues/819
ctx->location_field_set = r->headers_out.location != NULL;
// TODO(jefftk): is this thread safe? // TODO(jefftk): is this thread safe?
copy_response_headers_from_ngx(r, ctx->base_fetch->response_headers()); copy_response_headers_from_ngx(r, ctx->base_fetch->response_headers());
@@ -3074,10 +3116,15 @@ ngx_int_t ps_init_module(ngx_cycle_t* cycle) {
"UseNativeFetcher is on, please configure a resolver."); "UseNativeFetcher is on, please configure a resolver.");
return NGX_ERROR; return NGX_ERROR;
} }
// Update logging to the configured error_log in the http{} block.
cfg_m->driver_factory->LoggingInit(cycle->log); cfg_m->driver_factory->LoggingInit(cycle->log);
cfg_m->driver_factory->RootInit(); cfg_m->driver_factory->RootInit();
} else { } else {
if (!factory_init_called) {
cfg_m->driver_factory->LoggingInit(cycle->log);
cfg_m->driver_factory->Init();
factory_init_called = true;
}
delete cfg_m->driver_factory; delete cfg_m->driver_factory;
cfg_m->driver_factory = NULL; cfg_m->driver_factory = NULL;
} }
@@ -3114,11 +3161,11 @@ ngx_int_t ps_init_child_process(ngx_cycle_t* cycle) {
// Some server{} blocks may not have a ServerContext in that case we must // Some server{} blocks may not have a ServerContext in that case we must
// not instantiate a ProxyFetchFactory. // not instantiate a ProxyFetchFactory.
if (cfg_s->server_context != NULL) { if (cfg_s->server_context != NULL) {
cfg_s->proxy_fetch_factory = new ProxyFetchFactory(cfg_s->server_context);
ngx_http_core_loc_conf_t* clcf = static_cast<ngx_http_core_loc_conf_t*>( ngx_http_core_loc_conf_t* clcf = static_cast<ngx_http_core_loc_conf_t*>(
cscfp[s]->ctx->loc_conf[ngx_http_core_module.ctx_index]); cscfp[s]->ctx->loc_conf[ngx_http_core_module.ctx_index]);
cfg_m->driver_factory->SetServerContextMessageHandler( cfg_m->driver_factory->SetServerContextMessageHandler(
cfg_s->server_context, clcf->error_log); cfg_s->server_context, clcf->error_log);
cfg_s->proxy_fetch_factory = new ProxyFetchFactory(cfg_s->server_context);
} }
} }
+1
View File
@@ -107,6 +107,7 @@ typedef struct {
// We need to remember the URL here as well since we may modify what NGX // We need to remember the URL here as well since we may modify what NGX
// gets by stripping our special query params and honoring X-Forwarded-Proto. // gets by stripping our special query params and honoring X-Forwarded-Proto.
GoogleString url_string; GoogleString url_string;
bool location_field_set;
} ps_request_ctx_t; } ps_request_ctx_t;
+4
View File
@@ -498,6 +498,10 @@ NgxRewriteOptions* NgxRewriteOptions::Clone() const {
return options; return options;
} }
void NgxRewriteOptions::Merge(const RewriteOptions& src) {
SystemRewriteOptions::Merge(src);
}
const NgxRewriteOptions* NgxRewriteOptions::DynamicCast( const NgxRewriteOptions* NgxRewriteOptions::DynamicCast(
const RewriteOptions* instance) { const RewriteOptions* instance) {
return dynamic_cast<const NgxRewriteOptions*>(instance); return dynamic_cast<const NgxRewriteOptions*>(instance);
+1
View File
@@ -140,6 +140,7 @@ class NgxRewriteOptions : public SystemRewriteOptions {
// Make an identical copy of these options and return it. // Make an identical copy of these options and return it.
virtual NgxRewriteOptions* Clone() const; virtual NgxRewriteOptions* Clone() const;
virtual void Merge(const RewriteOptions& src);
// Returns a suitably down cast version of 'instance' if it is an instance // Returns a suitably down cast version of 'instance' if it is an instance
// of this class, NULL if not. // of this class, NULL if not.