Skip to content

Commit 912c787

Browse files
committed
synchronized with lua-nginx-module #c5135a0 (removed compatibility code with old NGINX versions).
1 parent f393400 commit 912c787

26 files changed

+69
-369
lines changed

src/http/ngx_http_lua_accessby.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,6 @@ ngx_http_lua_access_handler(ngx_http_request_t *r)
145145
ngx_http_lua_generic_phase_post_read);
146146

147147
if (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE) {
148-
#if (nginx_version < 1002006) || \
149-
(nginx_version >= 1003000 && nginx_version < 1003009)
150-
r->main->count--;
151-
#endif
152-
153148
return rc;
154149
}
155150

src/http/ngx_http_lua_bodyfilterby.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,7 @@ ngx_http_lua_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
314314
return NGX_ERROR;
315315
}
316316

317-
#if nginx_version >= 1001004
318317
ngx_chain_update_chains(r->pool,
319-
#else
320-
ngx_chain_update_chains(
321-
#endif
322318
&ctx->free_bufs, &ctx->busy_bufs, &out,
323319
(ngx_buf_tag_t) &ngx_http_lua_module);
324320

src/http/ngx_http_lua_headers.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static int ngx_http_lua_ngx_req_raw_header(lua_State *L);
2222
static int ngx_http_lua_ngx_req_header_set_helper(lua_State *L);
2323
static int ngx_http_lua_ngx_req_header_set(lua_State *L);
2424
static int ngx_http_lua_ngx_resp_get_headers(lua_State *L);
25-
#if nginx_version >= 1011011
25+
#if defined(nginx_version) && nginx_version >= 1011011
2626
void ngx_http_lua_ngx_raw_header_cleanup(void *data);
2727
#endif
2828

@@ -102,7 +102,7 @@ ngx_http_lua_ngx_req_raw_header(lua_State *L)
102102
size_t size;
103103
ngx_buf_t *b, *first = NULL;
104104
ngx_int_t i, j;
105-
#if nginx_version >= 1011011
105+
#if defined(nginx_version) && nginx_version >= 1011011
106106
ngx_buf_t **bb;
107107
ngx_chain_t *cl;
108108
ngx_http_lua_main_conf_t *lmcf;
@@ -123,7 +123,7 @@ ngx_http_lua_ngx_req_raw_header(lua_State *L)
123123
return luaL_error(L, "no request object found");
124124
}
125125

126-
#if nginx_version >= 1011011
126+
#if defined(nginx_version) && nginx_version >= 1011011
127127
lmcf = ngx_http_get_module_main_conf(r, ngx_http_lua_module);
128128
#endif
129129

@@ -143,7 +143,7 @@ ngx_http_lua_ngx_req_raw_header(lua_State *L)
143143
dd("hc->nbusy: %d", (int) hc->nbusy);
144144

145145
if (hc->nbusy) {
146-
#if nginx_version >= 1011011
146+
#if defined(nginx_version) && nginx_version >= 1011011
147147
dd("hc->busy: %p %p %p %p", hc->busy->buf->start, hc->busy->buf->pos,
148148
hc->busy->buf->last, hc->busy->buf->end);
149149
#else
@@ -185,7 +185,7 @@ ngx_http_lua_ngx_req_raw_header(lua_State *L)
185185
dd("size: %d", (int) size);
186186

187187
if (hc->nbusy) {
188-
#if nginx_version >= 1011011
188+
#if defined(nginx_version) && nginx_version >= 1011011
189189
if (hc->nbusy > lmcf->busy_buf_ptr_count) {
190190
if (lmcf->busy_buf_ptrs) {
191191
ngx_free(lmcf->busy_buf_ptrs);
@@ -208,7 +208,7 @@ ngx_http_lua_ngx_req_raw_header(lua_State *L)
208208
#endif
209209
b = NULL;
210210

211-
#if nginx_version >= 1011011
211+
#if defined(nginx_version) && nginx_version >= 1011011
212212
bb = lmcf->busy_buf_ptrs;
213213
for (i = hc->nbusy; i > 0; i--) {
214214
b = bb[i - 1];
@@ -291,7 +291,7 @@ ngx_http_lua_ngx_req_raw_header(lua_State *L)
291291

292292
if (hc->nbusy) {
293293

294-
#if nginx_version >= 1011011
294+
#if defined(nginx_version) && nginx_version >= 1011011
295295
bb = lmcf->busy_buf_ptrs;
296296
for (i = hc->nbusy - 1; i >= 0; i--) {
297297
b = bb[i];
@@ -1138,7 +1138,7 @@ ngx_http_lua_ffi_get_resp_header(ngx_http_request_t *r,
11381138
}
11391139

11401140

1141-
#if nginx_version >= 1011011
1141+
#if defined(nginx_version) && nginx_version >= 1011011
11421142
void
11431143
ngx_http_lua_ngx_raw_header_cleanup(void *data)
11441144
{

src/http/ngx_http_lua_headers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
void ngx_http_lua_inject_resp_header_api(lua_State *L);
1616
void ngx_http_lua_inject_req_header_api(lua_State *L);
1717
void ngx_http_lua_create_headers_metatable(ngx_log_t *log, lua_State *L);
18-
#if nginx_version >= 1011011
18+
#if defined(nginx_version) && nginx_version >= 1011011
1919
void ngx_http_lua_ngx_raw_header_cleanup(void *data);
2020
#endif
2121

src/http/ngx_http_lua_headers_in.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,17 @@ static ngx_http_lua_set_header_t ngx_http_lua_set_handlers[] = {
5656
offsetof(ngx_http_headers_in_t, if_modified_since),
5757
ngx_http_set_builtin_header },
5858

59-
#if defined(nginx_version) && nginx_version >= 9002
6059
{ ngx_string("If-Unmodified-Since"),
6160
offsetof(ngx_http_headers_in_t, if_unmodified_since),
6261
ngx_http_set_builtin_header },
63-
#endif
6462

65-
#if defined(nginx_version) && nginx_version >= 1003003
6663
{ ngx_string("If-Match"),
6764
offsetof(ngx_http_headers_in_t, if_match),
6865
ngx_http_set_builtin_header },
6966

7067
{ ngx_string("If-None-Match"),
7168
offsetof(ngx_http_headers_in_t, if_none_match),
7269
ngx_http_set_builtin_header },
73-
#endif
7470

7571
{ ngx_string("User-Agent"),
7672
offsetof(ngx_http_headers_in_t, user_agent),
@@ -104,11 +100,9 @@ static ngx_http_lua_set_header_t ngx_http_lua_set_handlers[] = {
104100
offsetof(ngx_http_headers_in_t, expect),
105101
ngx_http_set_builtin_header },
106102

107-
#if defined(nginx_version) && nginx_version >= 1003013
108103
{ ngx_string("Upgrade"),
109104
offsetof(ngx_http_headers_in_t, upgrade),
110105
ngx_http_set_builtin_header },
111-
#endif
112106

113107
#if (NGX_HTTP_GZIP)
114108
{ ngx_string("Accept-Encoding"),

src/http/ngx_http_lua_req_body.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,6 @@ ngx_http_lua_ngx_req_read_body(lua_State *L)
114114

115115
rc = ngx_http_read_client_request_body(r, ngx_http_lua_req_body_post_read);
116116

117-
#if (nginx_version < 1002006) || \
118-
(nginx_version >= 1003000 && nginx_version < 1003009)
119-
r->main->count--;
120-
#endif
121-
122117
if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
123118
ctx->exit_code = rc;
124119
ctx->exited = 1;
@@ -130,11 +125,8 @@ ngx_http_lua_ngx_req_read_body(lua_State *L)
130125
return lua_yield(L, 0);
131126
}
132127

133-
#if (nginx_version >= 1002006 && nginx_version < 1003000) || \
134-
nginx_version >= 1003009
135128
r->main->count--;
136129
dd("decrement r->main->count: %d", (int) r->main->count);
137-
#endif
138130

139131
if (rc == NGX_AGAIN) {
140132
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,

src/http/ngx_http_lua_rewriteby.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,6 @@ ngx_http_lua_rewrite_handler(ngx_http_request_t *r)
149149
ngx_http_lua_generic_phase_post_read);
150150

151151
if (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE) {
152-
#if (nginx_version < 1002006) || \
153-
(nginx_version >= 1003000 && nginx_version < 1003009)
154-
r->main->count--;
155-
#endif
156-
157152
return rc;
158153
}
159154

src/http/ngx_http_lua_ssl_session_fetchby.c

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -262,26 +262,11 @@ ngx_http_lua_ssl_sess_fetch_handler(ngx_ssl_conn_t *ssl_conn,
262262

263263
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
264264

265-
#if defined(nginx_version) && nginx_version >= 1003014
266-
267-
# if nginx_version >= 1009000
268-
265+
#if defined(nginx_version) && nginx_version >= 1009000
269266
ngx_set_connection_log(fc, clcf->error_log);
270267

271-
# else
272-
273-
ngx_http_set_connection_log(fc, clcf->error_log);
274-
275-
# endif
276-
277268
#else
278-
279-
fc->log->file = clcf->error_log->file;
280-
281-
if (!(fc->log->log_level & NGX_LOG_DEBUG_CONNECTION)) {
282-
fc->log->log_level = clcf->error_log->log_level;
283-
}
284-
269+
ngx_http_set_connection_log(fc, clcf->error_log);
285270
#endif
286271

287272
if (cctx == NULL) {

src/http/ngx_http_lua_ssl_session_storeby.c

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -224,25 +224,11 @@ ngx_http_lua_ssl_sess_store_handler(ngx_ssl_conn_t *ssl_conn,
224224

225225
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
226226

227-
#if defined(nginx_version) && nginx_version >= 1003014
228-
229-
# if nginx_version >= 1009000
230-
227+
#if defined(nginx_version) && nginx_version >= 1009000
231228
ngx_set_connection_log(fc, clcf->error_log);
232229

233-
# else
234-
235-
ngx_http_set_connection_log(fc, clcf->error_log);
236-
237-
# endif
238-
239230
#else
240-
241-
fc->log->file = clcf->error_log->file;
242-
243-
if (!(fc->log->log_level & NGX_LOG_DEBUG_CONNECTION)) {
244-
fc->log->log_level = clcf->error_log->log_level;
245-
}
231+
ngx_http_set_connection_log(fc, clcf->error_log);
246232

247233
#endif
248234

src/http/ngx_http_lua_subrequest.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,11 +1081,7 @@ ngx_http_lua_post_subrequest(ngx_http_request_t *r, void *data, ngx_int_t rc)
10811081

10821082
if (ctx->body) {
10831083

1084-
#if defined(nginx_version) && nginx_version >= 1001004
10851084
ngx_chain_update_chains(r->pool,
1086-
#else
1087-
ngx_chain_update_chains(
1088-
#endif
10891085
&pr_ctx->free_bufs, &pr_ctx->busy_bufs,
10901086
&ctx->body,
10911087
(ngx_buf_tag_t) &ngx_http_lua_module);
@@ -1457,7 +1453,7 @@ ngx_http_lua_subrequest(ngx_http_request_t *r,
14571453
ngx_http_request_t *sr;
14581454
ngx_http_core_srv_conf_t *cscf;
14591455

1460-
#if nginx_version >= 1009005
1456+
#if defined(nginx_version) && nginx_version >= 1009005
14611457

14621458
if (r->subrequests == 0) {
14631459
#if defined(NGX_DTRACE) && NGX_DTRACE
@@ -1576,7 +1572,7 @@ ngx_http_lua_subrequest(ngx_http_request_t *r,
15761572

15771573
sr->uri_changes = NGX_HTTP_MAX_URI_CHANGES + 1;
15781574

1579-
#if nginx_version >= 1009005
1575+
#if defined(nginx_version) && nginx_version >= 1009005
15801576
sr->subrequests = r->subrequests - 1;
15811577
#endif
15821578

0 commit comments

Comments
 (0)