Make sure RewriteDriverFactory::default_options gets the top-level proces-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).
This commit is contained in:
committed by
Jeffrey Crowell
parent
21f9b5c9e3
commit
e0a3bf223a
@@ -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_;
|
||||
|
||||
Reference in New Issue
Block a user