@@ -749,6 +749,11 @@ ngx_command_t ps_commands[] = {
749
749
ngx_null_command
750
750
};
751
751
752
+ bool ps_disabled (ps_srv_conf_t * cfg_s) {
753
+ return cfg_s->server_context == NULL ||
754
+ cfg_s->server_context ->config ()->unplugged ();
755
+ }
756
+
752
757
void ps_ignore_sigpipe () {
753
758
struct sigaction act;
754
759
ngx_memzero (&act, sizeof (act));
@@ -881,8 +886,7 @@ char* ps_configure(ngx_conf_t* cf,
881
886
ps_main_conf_t * cfg_m = static_cast <ps_main_conf_t *>(
882
887
ngx_http_cycle_get_module_main_conf (cf->cycle , ngx_pagespeed));
883
888
if (*options == NULL ) {
884
- *options = new NgxRewriteOptions (
885
- cfg_m->driver_factory ->thread_system ());
889
+ *options = new NgxRewriteOptions (cfg_m->driver_factory ->thread_system ());
886
890
}
887
891
888
892
ProcessScriptVariablesMode script_mode =
@@ -1191,7 +1195,7 @@ char* ps_merge_loc_conf(ngx_conf_t* cf, void* parent, void* child) {
1191
1195
ps_srv_conf_t * cfg_s = static_cast <ps_srv_conf_t *>(
1192
1196
ngx_http_conf_get_module_srv_conf (cf, ngx_pagespeed));
1193
1197
1194
- if (cfg_s-> server_context == NULL ) {
1198
+ if (ps_disabled ( cfg_s) ) {
1195
1199
// Pagespeed options cannot be defined only in location blocks. There must
1196
1200
// be at least a single "pagespeed off" in the main block or a server
1197
1201
// block.
@@ -1698,7 +1702,7 @@ void ps_release_request_context(void* data) {
1698
1702
RequestRouting::Response ps_route_request (ngx_http_request_t * r) {
1699
1703
ps_srv_conf_t * cfg_s = ps_get_srv_config (r);
1700
1704
1701
- if (!cfg_s-> server_context -> global_options ()-> enabled ( )) {
1705
+ if (ps_disabled (cfg_s )) {
1702
1706
// Not enabled for this server block.
1703
1707
return RequestRouting::kPagespeedDisabled ;
1704
1708
}
@@ -2050,8 +2054,8 @@ ngx_int_t ps_resource_handler(ngx_http_request_t* r,
2050
2054
if (options->in_place_rewriting_enabled () &&
2051
2055
options->enabled () &&
2052
2056
options->IsAllowed (url.Spec ())) {
2053
- ps_create_base_fetch (url.Spec (), ctx, request_context, request_headers. release (),
2054
- kIproLookup , options);
2057
+ ps_create_base_fetch (url.Spec (), ctx, request_context,
2058
+ request_headers. release (), kIproLookup , options);
2055
2059
2056
2060
// Do not store driver in request_context, it's not safe.
2057
2061
RewriteDriver* driver;
@@ -2277,8 +2281,7 @@ ngx_http_output_body_filter_pt ngx_http_next_body_filter;
2277
2281
// nginx so it can send them out to the browser.
2278
2282
ngx_int_t ps_html_rewrite_header_filter (ngx_http_request_t * r) {
2279
2283
ps_srv_conf_t * cfg_s = ps_get_srv_config (r);
2280
- if (cfg_s->server_context == NULL ) {
2281
- // Pagespeed is on for some server block but not this one.
2284
+ if (ps_disabled (cfg_s)) {
2282
2285
return ngx_http_next_header_filter (r);
2283
2286
}
2284
2287
@@ -2362,8 +2365,7 @@ ngx_int_t ps_html_rewrite_header_filter(ngx_http_request_t* r) {
2362
2365
2363
2366
ngx_int_t ps_html_rewrite_body_filter (ngx_http_request_t * r, ngx_chain_t * in) {
2364
2367
ps_srv_conf_t * cfg_s = ps_get_srv_config (r);
2365
- if (cfg_s->server_context == NULL ) {
2366
- // Pagespeed is on for some server block but not this one.
2368
+ if (ps_disabled (cfg_s)) {
2367
2369
return ngx_http_next_body_filter (r, in);
2368
2370
}
2369
2371
@@ -2887,8 +2889,8 @@ ngx_int_t ps_beacon_handler(ngx_http_request_t* r) {
2887
2889
// supply it to the user.
2888
2890
ngx_int_t ps_content_handler (ngx_http_request_t * r) {
2889
2891
ps_srv_conf_t * cfg_s = ps_get_srv_config (r);
2890
- if (cfg_s-> server_context == NULL ) {
2891
- // Pagespeed is on for some server block but not this one .
2892
+ if (ps_disabled ( cfg_s) ) {
2893
+ // Pagespeed is not on for this server block.
2892
2894
return NGX_DECLINED;
2893
2895
}
2894
2896
0 commit comments