blob: 190a732c6276e4bd02f0a3251179e6316c00d69f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
From c67f6642440380a693329733f7148bfa4fed5459 Mon Sep 17 00:00:00 2001
From: Otto van der Schaaf <oschaaf@we-amp.com>
Date: Mon, 21 Aug 2017 12:25:50 +0200
Subject: [PATCH] nginx 1.13.4: Fix compilation error (#1453)
* Compilation of ngx_pagespeed broke with the following commit in
nginx: https://github.com/nginx/nginx/commit/129b06dc5dfab7b4513a4f274b3778cd9b8a6a22
This change intends to unbreak it while maintaining backwards
compatibility.
* updates the nginx testing-dependency to 1.13.4
Fixes https://github.com/pagespeed/ngx_pagespeed/issues/1451
---
src/ngx_pagespeed.cc | 14 +++++++++++++-
testing-dependencies/nginx | 2 +-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/ngx_pagespeed.cc b/src/ngx_pagespeed.cc
index 8487f8ab6..97f07d98c 100644
--- a/src/ngx_pagespeed.cc
+++ b/src/ngx_pagespeed.cc
@@ -3019,13 +3019,17 @@ ngx_int_t ps_preaccess_handler(ngx_http_request_t* r) {
ph = cmcf->phase_engine.handlers;
i = r->phase_handler;
+
// move handlers before try_files && content phase
+ // As of nginx 1.13.4 we will be right before the try_files module
+ #if (nginx_version < 1013004)
while (ph[i + 1].checker != ngx_http_core_try_files_phase &&
ph[i + 1].checker != ngx_http_core_content_phase) {
ph[i] = ph[i + 1];
ph[i].next--;
i++;
}
+ #endif
// insert ps phase handler
ph[i].checker = ps_phase_handler;
@@ -3081,8 +3085,16 @@ ngx_int_t ps_init(ngx_conf_t* cf) {
ngx_http_core_main_conf_t* cmcf = static_cast<ngx_http_core_main_conf_t*>(
ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module));
+ int phase = NGX_HTTP_PRECONTENT_PHASE;
+
+ // As of nginx 1.13.4, try_files has changed.
+#if (nginx_version < 1013004)
+ phase = NGX_HTTP_PREACCESS_PHASE;
+#endif
+
ngx_http_handler_pt* h = static_cast<ngx_http_handler_pt*>(
- ngx_array_push(&cmcf->phases[NGX_HTTP_PREACCESS_PHASE].handlers));
+ ngx_array_push(&cmcf->phases[phase].handlers));
+
if (h == NULL) {
return NGX_ERROR;
}
|