Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Commit

Permalink
Make sure RewriteDriverFactory::default_options gets the top-level pr…
Browse files Browse the repository at this point in the history
…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 Jul 21, 2016
1 parent 21f9b5c commit e0a3bf2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/ngx_pagespeed.cc
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion src/ngx_rewrite_driver_factory.cc
Expand Up @@ -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())),
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 1 addition & 5 deletions src/ngx_rewrite_driver_factory.h
Expand Up @@ -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;
Expand Down Expand Up @@ -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_;
Expand Down

0 comments on commit e0a3bf2

Please sign in to comment.