Skip to content

Commit e2ef03b

Browse files
authored
Merge pull request #9 from fdintino/fix-tests-and-segfaults
Fix tests and segfaults
2 parents 1449591 + cd34b66 commit e2ef03b

File tree

7 files changed

+20
-14
lines changed

7 files changed

+20
-14
lines changed

ngx_cache_purge_module.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ ngx_http_fastcgi_cache_purge_conf(ngx_conf_t *cf, ngx_command_t *cmd,
387387
clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
388388

389389
cplcf->fastcgi.enable = 0;
390+
cplcf->conf = &cplcf->fastcgi;
390391
clcf->handler = ngx_http_fastcgi_cache_purge_handler;
391392

392393
return NGX_CONF_OK;
@@ -673,6 +674,7 @@ ngx_http_proxy_cache_purge_conf(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
673674
clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
674675

675676
cplcf->proxy.enable = 0;
677+
cplcf->conf = &cplcf->proxy;
676678
clcf->handler = ngx_http_proxy_cache_purge_handler;
677679

678680
return NGX_CONF_OK;
@@ -897,6 +899,7 @@ ngx_http_scgi_cache_purge_conf(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) {
897899
clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
898900

899901
cplcf->scgi.enable = 0;
902+
cplcf->conf = &cplcf->scgi;
900903
clcf->handler = ngx_http_scgi_cache_purge_handler;
901904

902905
return NGX_CONF_OK;
@@ -1144,6 +1147,7 @@ ngx_http_uwsgi_cache_purge_conf(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
11441147
clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
11451148

11461149
cplcf->uwsgi.enable = 0;
1150+
cplcf->conf = &cplcf->uwsgi;
11471151
clcf->handler = ngx_http_uwsgi_cache_purge_handler;
11481152

11491153
return NGX_CONF_OK;
@@ -1249,9 +1253,11 @@ ngx_http_purge_file_cache_delete_partial_file(ngx_tree_ctx_t *ctx, ngx_str_t *pa
12491253
} else {
12501254
ngx_file_t file;
12511255

1256+
ngx_memzero(&file, sizeof(ngx_file_t));
12521257
file.offset = file.sys_offset = 0;
12531258
file.fd = ngx_open_file(path->data, NGX_FILE_RDONLY, NGX_FILE_OPEN,
12541259
NGX_FILE_DEFAULT_ACCESS);
1260+
file.log = ctx->log;
12551261

12561262
/* I don't know if it's a good idea to use the ngx_cycle pool for this,
12571263
but the request is not available here */

t/proxy1.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ qr/\[(warn|error|crit|alert|emerg)\]/
9292
--- config eval: $::config
9393
--- request
9494
PURGE /purge/proxy/passwd
95-
--- error_code: 404
95+
--- error_code: 412
9696
--- response_headers
9797
Content-Type: text/html
98-
--- response_body_like: 404 Not Found
98+
--- response_body_like: 412 Precondition Failed
9999
--- timeout: 10
100100
--- no_error_log eval
101101
qr/\[(warn|error|crit|alert|emerg)\]/

t/proxy1_vars.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ qr/\[(warn|error|crit|alert|emerg)\]/
9494
--- config eval: $::config
9595
--- request
9696
PURGE /purge/proxy/passwd
97-
--- error_code: 404
97+
--- error_code: 412
9898
--- response_headers
9999
Content-Type: text/html
100-
--- response_body_like: 404 Not Found
100+
--- response_body_like: 412 Precondition Failed
101101
--- timeout: 10
102102
--- no_error_log eval
103103
qr/\[(warn|error|crit|alert|emerg)\]/

t/proxy2.t

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ qr/\[(warn|error|crit|alert|emerg)\]/
124124
--- config eval: $::config
125125
--- request
126126
PURGE /proxy/passwd
127-
--- error_code: 404
127+
--- error_code: 412
128128
--- response_headers
129129
Content-Type: text/html
130-
--- response_body_like: 404 Not Found
130+
--- response_body_like: 412 Precondition Failed
131131
--- timeout: 10
132132
--- no_error_log eval
133133
qr/\[(warn|error|crit|alert|emerg)\]/
@@ -190,10 +190,10 @@ qr/\[(warn|error|crit|alert|emerg)\]/
190190
--- config eval: $::config_allowed
191191
--- request
192192
PURGE /proxy/passwd
193-
--- error_code: 404
193+
--- error_code: 412
194194
--- response_headers
195195
Content-Type: text/html
196-
--- response_body_like: 404 Not Found
196+
--- response_body_like: 412 Precondition Failed
197197
--- timeout: 10
198198
--- no_error_log eval
199199
qr/\[(warn|error|crit|alert|emerg)\]/

t/proxy2_vars.t

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ qr/\[(warn|error|crit|alert|emerg)\]/
127127
--- config eval: $::config
128128
--- request
129129
PURGE /proxy/passwd
130-
--- error_code: 404
130+
--- error_code: 412
131131
--- response_headers
132132
Content-Type: text/html
133-
--- response_body_like: 404 Not Found
133+
--- response_body_like: 412 Precondition Failed
134134
--- timeout: 10
135135
--- no_error_log eval
136136
qr/\[(warn|error|crit|alert|emerg)\]/
@@ -193,10 +193,10 @@ qr/\[(warn|error|crit|alert|emerg)\]/
193193
--- config eval: $::config_allowed
194194
--- request
195195
PURGE /proxy/passwd
196-
--- error_code: 404
196+
--- error_code: 412
197197
--- response_headers
198198
Content-Type: text/html
199-
--- response_body_like: 404 Not Found
199+
--- response_body_like: 412 Precondition Failed
200200
--- timeout: 10
201201
--- no_error_log eval
202202
qr/\[(warn|error|crit|alert|emerg)\]/

t/proxy3.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ our $config = <<'_EOC_';
2525
2626
2727
location = /etc/passwd {
28-
root /var/www/html;
28+
root /;
2929
}
3030
_EOC_
3131

t/proxy4.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ our $config = <<'_EOC_';
2525
2626
2727
location = /etc/passwd {
28-
root /var/www/html;
28+
root /;
2929
}
3030
_EOC_
3131

0 commit comments

Comments
 (0)