Permalink
Browse files

Make sure RewriteDriverFactory::default_options gets the top-level pr…

…oces-scope options. (#1203)

Needed for ImageMaxRewritesAtOnce to work with latest revisions.

Fix for when there is only server-level configuration (#1218)

When there is no top-level configuration but only server configuration,
we don't have main options to set and consider. This prevents
a NULL dereference in that case. (Later on we'll writes out a message
about why we cannot startup with this configuration).
  • Loading branch information...
morlovich authored and crowell committed May 20, 2016
1 parent 21f9b5c commit e0a3bf223a6ea4914c1d34944f94c8aef8ef0db7
Showing with 10 additions and 7 deletions.
  1. +1 −1 src/ngx_pagespeed.cc
  2. +8 −1 src/ngx_rewrite_driver_factory.cc
  3. +1 −5 src/ngx_rewrite_driver_factory.h
@@ -1094,7 +1094,7 @@ char* ps_merge_srv_conf(ngx_conf_t* cf, void* parent, void* child) {

ps_main_conf_t* cfg_m = static_cast<ps_main_conf_t*>(
ngx_http_conf_get_module_main_conf(cf, ngx_pagespeed));
cfg_m->driver_factory->set_main_conf(parent_cfg_s->options);
cfg_m->driver_factory->SetMainConf(parent_cfg_s->options);
cfg_s->server_context = cfg_m->driver_factory->MakeNgxServerContext(
"dummy_hostname", dummy_port);
// The server context sets some options when we call global_options(). So
@@ -69,7 +69,6 @@ NgxRewriteDriverFactory::NgxRewriteDriverFactory(
SystemThreadSystem* system_thread_system, StringPiece hostname, int port)
: SystemRewriteDriverFactory(process_context, system_thread_system,
NULL /* default shared memory runtime */, hostname, port),
main_conf_(NULL),
threads_started_(false),
ngx_message_handler_(
new NgxMessageHandler(timer(), thread_system()->NewMutex())),
@@ -208,6 +207,14 @@ void NgxRewriteDriverFactory::StartThreads() {
threads_started_ = true;
}

void NgxRewriteDriverFactory::SetMainConf(NgxRewriteOptions* main_options) {
// Propagate process-scope options from the copy we had during nginx option
// parsing to our own.
if (main_options != NULL) {
default_options()->MergeOnlyProcessScopeOptions(*main_options);
}
}

void NgxRewriteDriverFactory::LoggingInit(
ngx_log_t* log, bool may_install_crash_handler) {
log_ = log;
@@ -90,7 +90,7 @@ class NgxRewriteDriverFactory : public SystemRewriteDriverFactory {
InitStats(statistics);
}

void set_main_conf(NgxRewriteOptions* main_conf) { main_conf_ = main_conf; }
void SetMainConf(NgxRewriteOptions* main_conf);

void set_resolver(ngx_resolver_t* resolver) {
resolver_ = resolver;
@@ -133,10 +133,6 @@ class NgxRewriteDriverFactory : public SystemRewriteDriverFactory {
private:
Timer* timer_;

// main_conf will have only options set in the main block. It may be NULL,
// and we do not take ownership.
NgxRewriteOptions* main_conf_;

bool threads_started_;
NgxMessageHandler* ngx_message_handler_;
NgxMessageHandler* ngx_html_parse_message_handler_;

0 comments on commit e0a3bf2

Please sign in to comment.