@@ -332,9 +332,9 @@ class ApacheProcessContext {
332332 return factory_.get ();
333333 }
334334
335- // Checks cmd to see if it's used in a vhost or conditional context, and
336- // if so, if that's an error or warning condition .
337- const char * CheckCommandForVhost (const cmd_parms* cmd);
335+ // Checks cmd to see if it's process scope, and if so if it's used in an
336+ // incorrect context, returning an error message if so .
337+ const char * CheckProcessScope (const cmd_parms* cmd, bool * is_process_scope );
338338
339339 scoped_ptr<ApacheRewriteDriverFactory> factory_;
340340 // Process-scoped static variable cleanups, mainly for valgrind.
@@ -949,6 +949,18 @@ int pagespeed_post_config(apr_pool_t* pool, apr_pool_t* plog, apr_pool_t* ptemp,
949949 CHECK (server_context != NULL );
950950 server_contexts.push_back (server_context);
951951 }
952+
953+ // We also want propagate all the per-process options to each vhost. The
954+ // normal merge in merge_server_config isn't enough since that merges the
955+ // non-per process things from a dummy ServerContext corresponding to the
956+ // top-level config, not ApacheRewriteDriverFactory::default_options where
957+ // the process scope options go.
958+ //
959+ // We do this here rather than merge_server_config since we want to touch
960+ // the ServerContext corresponding to the top-level/non-<VirtualHost>
961+ // block, too.
962+ server_context->global_config ()->MergeOnlyProcessScopeOptions (
963+ *factory->default_options ());
952964 }
953965
954966 GoogleString error_message;
@@ -1291,17 +1303,14 @@ static char* CheckGlobalOption(const cmd_parms* cmd,
12911303 return NULL ;
12921304}
12931305
1294- const char * ApacheProcessContext::CheckCommandForVhost (const cmd_parms* cmd) {
1295- // Only do the vhost_command_handling_map_ lookup if it's going
1296- // to be used by CheckGlobalOption.
1297- //
1298- // TODO(jmarantz): Add a scope argument ParseAndSetOptionFromName[123] and
1299- // let it do the error-checking & reporting.
1306+ const char * ApacheProcessContext::CheckProcessScope (
1307+ const cmd_parms* cmd, bool * is_process_scope) {
1308+ VhostCommandHandlingMap::const_iterator p =
1309+ vhost_command_handling_map_.find (cmd->cmd );
1310+ *is_process_scope = (p != vhost_command_handling_map_.end ());
13001311 const char * ret = NULL ;
13011312 if (cmd->server ->is_virtual || (cmd->directive ->data != NULL )) {
1302- VhostCommandHandlingMap::const_iterator p =
1303- vhost_command_handling_map_.find (cmd->cmd );
1304- if (p != vhost_command_handling_map_.end ()) {
1313+ if (*is_process_scope) {
13051314 ret = CheckGlobalOption (cmd, p->second , factory_->message_handler ());
13061315 }
13071316 }
@@ -1376,20 +1385,36 @@ static const char* ParseDirective(cmd_parms* cmd, void* data, const char* arg) {
13761385 if (directive.starts_with (prefix)) {
13771386 StringPiece option = directive.substr (prefix.size ());
13781387 GoogleString msg;
1388+
1389+ bool use_global_config = false ;
1390+ // See if it's a global option, and perhaps not in place.
1391+ ret = apache_process_context.CheckProcessScope (cmd, &use_global_config);
1392+ if (ret != NULL ) {
1393+ return ret;
1394+ }
1395+ // Options that are per-process are always parsed into
1396+ // ApacheRewriteDriverFactory::default_options(), and then propagated
1397+ // in the post-config hook (pagespeed_post_config).
1398+ if (use_global_config) {
1399+ config = ApacheConfig::DynamicCast (factory->default_options ());
1400+ }
1401+
13791402 // See whether generic RewriteOptions name handling can figure this one out.
13801403 RewriteOptions::OptionSettingResult result =
13811404 config->ParseAndSetOptionFromName1 (option, arg, &msg, handler);
13821405 if (result == RewriteOptions::kOptionNameUnknown ) {
13831406 // RewriteOptions didn't know; try the driver factory.
1407+ // TODO(morlovich): It may be cleaner to not have process-scope options
1408+ // in RewriteOptions at all, but rather something RewriteDriverFactory
1409+ // specific, as long as we can provide a painless way of integrating it
1410+ // in the server and parsing it (areas where the current manual approach
1411+ // fails).
13841412 result = factory->ParseAndSetOption1 (
13851413 option, arg,
13861414 !cmd->server ->is_virtual , // is_process_scope
13871415 &msg, handler);
13881416 }
13891417 if (StandardParsingHandled (cmd, result, msg, &ret)) {
1390- if (ret == NULL ) {
1391- ret = apache_process_context.CheckCommandForVhost (cmd);
1392- }
13931418 return ret;
13941419 }
13951420 }
@@ -1874,6 +1899,7 @@ void* merge_server_config(apr_pool_t* pool, void* base_conf, void* new_conf) {
18741899 new_non_spdy_overlay.release ());
18751900 }
18761901 }
1902+
18771903 return new_conf;
18781904}
18791905
0 commit comments