@@ -87,6 +87,7 @@ ngx_rtmp_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
8787 ngx_uint_t i , m , mi , s ;
8888 ngx_conf_t pcf ;
8989 ngx_array_t ports ;
90+ ngx_module_t * * modules ;
9091 ngx_rtmp_listen_t * listen ;
9192 ngx_rtmp_module_t * module ;
9293 ngx_rtmp_conf_ctx_t * ctx ;
@@ -102,6 +103,12 @@ ngx_rtmp_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
102103
103104 /* count the number of the rtmp modules and set up their indices */
104105
106+ #if (nginx_version >= 1009011 )
107+
108+ ngx_rtmp_max_module = ngx_count_modules (cf -> cycle , NGX_RTMP_MODULE );
109+
110+ #else
111+
105112 ngx_rtmp_max_module = 0 ;
106113 for (m = 0 ; ngx_modules [m ]; m ++ ) {
107114 if (ngx_modules [m ]-> type != NGX_RTMP_MODULE ) {
@@ -111,6 +118,8 @@ ngx_rtmp_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
111118 ngx_modules [m ]-> ctx_index = ngx_rtmp_max_module ++ ;
112119 }
113120
121+ #endif
122+
114123
115124 /* the rtmp main_conf context, it is the same in the all rtmp contexts */
116125
@@ -148,13 +157,19 @@ ngx_rtmp_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
148157 * of the all rtmp modules
149158 */
150159
151- for (m = 0 ; ngx_modules [m ]; m ++ ) {
152- if (ngx_modules [m ]-> type != NGX_RTMP_MODULE ) {
160+ #if (nginx_version >= 1009011 )
161+ modules = cf -> cycle -> modules ;
162+ #else
163+ modules = ngx_modules ;
164+ #endif
165+
166+ for (m = 0 ; modules [m ]; m ++ ) {
167+ if (modules [m ]-> type != NGX_RTMP_MODULE ) {
153168 continue ;
154169 }
155170
156- module = ngx_modules [m ]-> ctx ;
157- mi = ngx_modules [m ]-> ctx_index ;
171+ module = modules [m ]-> ctx ;
172+ mi = modules [m ]-> ctx_index ;
158173
159174 if (module -> create_main_conf ) {
160175 ctx -> main_conf [mi ] = module -> create_main_conf (cf );
@@ -181,12 +196,12 @@ ngx_rtmp_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
181196 pcf = * cf ;
182197 cf -> ctx = ctx ;
183198
184- for (m = 0 ; ngx_modules [m ]; m ++ ) {
185- if (ngx_modules [m ]-> type != NGX_RTMP_MODULE ) {
199+ for (m = 0 ; modules [m ]; m ++ ) {
200+ if (modules [m ]-> type != NGX_RTMP_MODULE ) {
186201 continue ;
187202 }
188203
189- module = ngx_modules [m ]-> ctx ;
204+ module = modules [m ]-> ctx ;
190205
191206 if (module -> preconfiguration ) {
192207 if (module -> preconfiguration (cf ) != NGX_OK ) {
@@ -212,13 +227,13 @@ ngx_rtmp_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
212227 cmcf = ctx -> main_conf [ngx_rtmp_core_module .ctx_index ];
213228 cscfp = cmcf -> servers .elts ;
214229
215- for (m = 0 ; ngx_modules [m ]; m ++ ) {
216- if (ngx_modules [m ]-> type != NGX_RTMP_MODULE ) {
230+ for (m = 0 ; modules [m ]; m ++ ) {
231+ if (modules [m ]-> type != NGX_RTMP_MODULE ) {
217232 continue ;
218233 }
219234
220- module = ngx_modules [m ]-> ctx ;
221- mi = ngx_modules [m ]-> ctx_index ;
235+ module = modules [m ]-> ctx ;
236+ mi = modules [m ]-> ctx_index ;
222237
223238 /* init rtmp{} main_conf's */
224239
@@ -283,12 +298,12 @@ ngx_rtmp_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
283298 return NGX_CONF_ERROR ;
284299 }
285300
286- for (m = 0 ; ngx_modules [m ]; m ++ ) {
287- if (ngx_modules [m ]-> type != NGX_RTMP_MODULE ) {
301+ for (m = 0 ; modules [m ]; m ++ ) {
302+ if (modules [m ]-> type != NGX_RTMP_MODULE ) {
288303 continue ;
289304 }
290305
291- module = ngx_modules [m ]-> ctx ;
306+ module = modules [m ]-> ctx ;
292307
293308 if (module -> postconfiguration ) {
294309 if (module -> postconfiguration (cf ) != NGX_OK ) {
0 commit comments