Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.

Commit 3bb65a9

Browse files
dsanders11oschaaf
authored andcommitted
Properly iterate modules (#1559)
1 parent 449045f commit 3bb65a9

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/ngx_gzip_setter.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ void NgxGZipSetter::Init(ngx_conf_t* cf) {
108108
#if (NGX_HTTP_GZIP)
109109
bool gzip_signature_mismatch = false;
110110
bool other_signature_mismatch = false;
111-
for (int m = 0; ngx_modules[m] != NULL; m++) {
112-
if (ngx_modules[m]->commands != NULL) {
113-
for (int c = 0; ngx_modules[m]->commands[c].name.len; c++) {
114-
ngx_command_t* current_command =& ngx_modules[m]->commands[c];
111+
for (int m = 0; cf->cycle->modules[m] != NULL; m++) {
112+
if (cf->cycle->modules[m]->commands != NULL) {
113+
for (int c = 0; cf->cycle->modules[m]->commands[c].name.len; c++) {
114+
ngx_command_t* current_command =& cf->cycle->modules[m]->commands[c];
115115

116116
// We look for the gzip command, and the exact signature we trust
117117
// this means configured as an config location offset
@@ -124,7 +124,7 @@ void NgxGZipSetter::Init(ngx_conf_t* cf) {
124124
if (IsNgxFlagCommand(current_command)) {
125125
current_command->set = ngx_gzip_redirect_conf_set_flag_slot;
126126
gzip_command_.command_ = current_command;
127-
gzip_command_.module_ = ngx_modules[m];
127+
gzip_command_.module_ = cf->cycle->modules[m];
128128
enabled_ = 1;
129129
} else {
130130
ngx_conf_log_error(
@@ -139,7 +139,7 @@ void NgxGZipSetter::Init(ngx_conf_t* cf) {
139139
if (IsNgxEnumCommand(current_command)) {
140140
current_command->set = ngx_gzip_redirect_conf_set_enum_slot;
141141
gzip_http_version_command_.command_ = current_command;
142-
gzip_http_version_command_.module_ = ngx_modules[m];
142+
gzip_http_version_command_.module_ = cf->cycle->modules[m];
143143
} else {
144144
ngx_conf_log_error(
145145
NGX_LOG_WARN, cf, 0,
@@ -153,7 +153,7 @@ void NgxGZipSetter::Init(ngx_conf_t* cf) {
153153
if (IsNgxBitmaskCommand(current_command)) {
154154
current_command->set = ngx_gzip_redirect_conf_set_bitmask_slot;
155155
gzip_proxied_command_.command_ = current_command;
156-
gzip_proxied_command_.module_ = ngx_modules[m];
156+
gzip_proxied_command_.module_ = cf->cycle->modules[m];
157157
} else {
158158
ngx_conf_log_error(
159159
NGX_LOG_WARN, cf, 0,
@@ -167,7 +167,7 @@ void NgxGZipSetter::Init(ngx_conf_t* cf) {
167167
if (IsNgxHttpTypesCommand(current_command)) {
168168
current_command->set = ngx_gzip_redirect_http_types_slot;
169169
gzip_http_types_command_.command_ = current_command;
170-
gzip_http_types_command_.module_ = ngx_modules[m];
170+
gzip_http_types_command_.module_ = cf->cycle->modules[m];
171171
} else {
172172
ngx_conf_log_error(
173173
NGX_LOG_WARN, cf, 0,
@@ -181,7 +181,7 @@ void NgxGZipSetter::Init(ngx_conf_t* cf) {
181181
if (IsNgxFlagCommand(current_command)) {
182182
current_command->set = ngx_gzip_redirect_conf_set_flag_slot;
183183
gzip_vary_command_.command_ = current_command;
184-
gzip_vary_command_.module_ = ngx_modules[m];
184+
gzip_vary_command_.module_ = cf->cycle->modules[m];
185185
} else {
186186
ngx_conf_log_error(
187187
NGX_LOG_WARN, cf, 0,

0 commit comments

Comments
 (0)