stop crashing when unplugged
This commit is contained in:
+11
-8
@@ -749,6 +749,11 @@ ngx_command_t ps_commands[] = {
|
||||
ngx_null_command
|
||||
};
|
||||
|
||||
bool ps_disabled(ps_srv_conf_t* cfg_s) {
|
||||
return cfg_s->server_context == NULL ||
|
||||
cfg_s->server_context->config()->unplugged();
|
||||
}
|
||||
|
||||
void ps_ignore_sigpipe() {
|
||||
struct sigaction act;
|
||||
ngx_memzero(&act, sizeof(act));
|
||||
@@ -1191,7 +1196,7 @@ char* ps_merge_loc_conf(ngx_conf_t* cf, void* parent, void* child) {
|
||||
ps_srv_conf_t* cfg_s = static_cast<ps_srv_conf_t*>(
|
||||
ngx_http_conf_get_module_srv_conf(cf, ngx_pagespeed));
|
||||
|
||||
if (cfg_s->server_context == NULL) {
|
||||
if (ps_disabled(cfg_s)) {
|
||||
// Pagespeed options cannot be defined only in location blocks. There must
|
||||
// be at least a single "pagespeed off" in the main block or a server
|
||||
// block.
|
||||
@@ -1698,7 +1703,7 @@ void ps_release_request_context(void* data) {
|
||||
RequestRouting::Response ps_route_request(ngx_http_request_t* r) {
|
||||
ps_srv_conf_t* cfg_s = ps_get_srv_config(r);
|
||||
|
||||
if (!cfg_s->server_context->global_options()->enabled()) {
|
||||
if (ps_disabled(cfg_s)) {
|
||||
// Not enabled for this server block.
|
||||
return RequestRouting::kPagespeedDisabled;
|
||||
}
|
||||
@@ -2277,8 +2282,7 @@ ngx_http_output_body_filter_pt ngx_http_next_body_filter;
|
||||
// nginx so it can send them out to the browser.
|
||||
ngx_int_t ps_html_rewrite_header_filter(ngx_http_request_t* r) {
|
||||
ps_srv_conf_t* cfg_s = ps_get_srv_config(r);
|
||||
if (cfg_s->server_context == NULL) {
|
||||
// Pagespeed is on for some server block but not this one.
|
||||
if (ps_disabled(cfg_s)) {
|
||||
return ngx_http_next_header_filter(r);
|
||||
}
|
||||
|
||||
@@ -2362,8 +2366,7 @@ ngx_int_t ps_html_rewrite_header_filter(ngx_http_request_t* r) {
|
||||
|
||||
ngx_int_t ps_html_rewrite_body_filter(ngx_http_request_t* r, ngx_chain_t* in) {
|
||||
ps_srv_conf_t* cfg_s = ps_get_srv_config(r);
|
||||
if (cfg_s->server_context == NULL) {
|
||||
// Pagespeed is on for some server block but not this one.
|
||||
if (ps_disabled(cfg_s)) {
|
||||
return ngx_http_next_body_filter(r, in);
|
||||
}
|
||||
|
||||
@@ -2887,8 +2890,8 @@ ngx_int_t ps_beacon_handler(ngx_http_request_t* r) {
|
||||
// supply it to the user.
|
||||
ngx_int_t ps_content_handler(ngx_http_request_t* r) {
|
||||
ps_srv_conf_t* cfg_s = ps_get_srv_config(r);
|
||||
if (cfg_s->server_context == NULL) {
|
||||
// Pagespeed is on for some server block but not this one.
|
||||
if (ps_disabled(cfg_s)) {
|
||||
// Pagespeed is not on for this server block.
|
||||
return NGX_DECLINED;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user