diff --git a/ngx_rtmp.c b/ngx_rtmp.c index 7c4a861..ad671d4 100644 --- a/ngx_rtmp.c +++ b/ngx_rtmp.c @@ -87,6 +87,7 @@ ngx_rtmp_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) ngx_uint_t i, m, mi, s; ngx_conf_t pcf; ngx_array_t ports; + ngx_module_t **modules; ngx_rtmp_listen_t *listen; ngx_rtmp_module_t *module; ngx_rtmp_conf_ctx_t *ctx; @@ -101,14 +102,18 @@ ngx_rtmp_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) *(ngx_rtmp_conf_ctx_t **) conf = ctx; /* count the number of the rtmp modules and set up their indices */ - +#if defined(nginx_version) && nginx_version >= 1009011 + modules = cf->cycle->modules; +#else + modules = ngx_modules; +#endif ngx_rtmp_max_module = 0; - for (m = 0; ngx_modules[m]; m++) { - if (ngx_modules[m]->type != NGX_RTMP_MODULE) { + for (m = 0; modules[m]; m++) { + if (modules[m]->type != NGX_RTMP_MODULE) { continue; } - ngx_modules[m]->ctx_index = ngx_rtmp_max_module++; + modules[m]->ctx_index = ngx_rtmp_max_module++; } @@ -148,13 +153,13 @@ ngx_rtmp_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) * of the all rtmp modules */ - for (m = 0; ngx_modules[m]; m++) { - if (ngx_modules[m]->type != NGX_RTMP_MODULE) { + for (m = 0; modules[m]; m++) { + if (modules[m]->type != NGX_RTMP_MODULE) { continue; } - module = ngx_modules[m]->ctx; - mi = ngx_modules[m]->ctx_index; + module = modules[m]->ctx; + mi = modules[m]->ctx_index; if (module->create_main_conf) { ctx->main_conf[mi] = module->create_main_conf(cf); @@ -181,12 +186,12 @@ ngx_rtmp_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) pcf = *cf; cf->ctx = ctx; - for (m = 0; ngx_modules[m]; m++) { - if (ngx_modules[m]->type != NGX_RTMP_MODULE) { + for (m = 0; modules[m]; m++) { + if (modules[m]->type != NGX_RTMP_MODULE) { continue; } - module = ngx_modules[m]->ctx; + module = modules[m]->ctx; if (module->preconfiguration) { if (module->preconfiguration(cf) != NGX_OK) { @@ -212,13 +217,13 @@ ngx_rtmp_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) cmcf = ctx->main_conf[ngx_rtmp_core_module.ctx_index]; cscfp = cmcf->servers.elts; - for (m = 0; ngx_modules[m]; m++) { - if (ngx_modules[m]->type != NGX_RTMP_MODULE) { + for (m = 0; modules[m]; m++) { + if (modules[m]->type != NGX_RTMP_MODULE) { continue; } - module = ngx_modules[m]->ctx; - mi = ngx_modules[m]->ctx_index; + module = modules[m]->ctx; + mi = modules[m]->ctx_index; /* init rtmp{} main_conf's */ @@ -283,12 +288,12 @@ ngx_rtmp_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) return NGX_CONF_ERROR; } - for (m = 0; ngx_modules[m]; m++) { - if (ngx_modules[m]->type != NGX_RTMP_MODULE) { + for (m = 0; modules[m]; m++) { + if (modules[m]->type != NGX_RTMP_MODULE) { continue; } - module = ngx_modules[m]->ctx; + module = modules[m]->ctx; if (module->postconfiguration) { if (module->postconfiguration(cf) != NGX_OK) { diff --git a/ngx_rtmp_core_module.c b/ngx_rtmp_core_module.c index 01303c6..517e4b8 100644 --- a/ngx_rtmp_core_module.c +++ b/ngx_rtmp_core_module.c @@ -332,6 +332,7 @@ ngx_rtmp_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) void *mconf; ngx_uint_t m; ngx_conf_t pcf; + ngx_module_t **modules; ngx_rtmp_module_t *module; ngx_rtmp_conf_ctx_t *ctx, *rtmp_ctx; ngx_rtmp_core_srv_conf_t *cscf, **cscfp; @@ -357,12 +358,17 @@ ngx_rtmp_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) return NGX_CONF_ERROR; } - for (m = 0; ngx_modules[m]; m++) { - if (ngx_modules[m]->type != NGX_RTMP_MODULE) { +#if defined(nginx_version) && nginx_version >= 1009011 + modules = cf->cycle->modules; +#else + modules = ngx_modules; +#endif + for (m = 0; modules[m]; m++) { + if (modules[m]->type != NGX_RTMP_MODULE) { continue; } - module = ngx_modules[m]->ctx; + module = modules[m]->ctx; if (module->create_srv_conf) { mconf = module->create_srv_conf(cf); @@ -370,7 +376,7 @@ ngx_rtmp_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) return NGX_CONF_ERROR; } - ctx->srv_conf[ngx_modules[m]->ctx_index] = mconf; + ctx->srv_conf[modules[m]->ctx_index] = mconf; } if (module->create_app_conf) { @@ -379,7 +385,7 @@ ngx_rtmp_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) return NGX_CONF_ERROR; } - ctx->app_conf[ngx_modules[m]->ctx_index] = mconf; + ctx->app_conf[modules[m]->ctx_index] = mconf; } } @@ -419,6 +425,7 @@ ngx_rtmp_core_application(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) ngx_int_t i; ngx_str_t *value; ngx_conf_t save; + ngx_module_t **modules; ngx_rtmp_module_t *module; ngx_rtmp_conf_ctx_t *ctx, *pctx; ngx_rtmp_core_srv_conf_t *cscf; @@ -438,17 +445,22 @@ ngx_rtmp_core_application(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) return NGX_CONF_ERROR; } - for (i = 0; ngx_modules[i]; i++) { - if (ngx_modules[i]->type != NGX_RTMP_MODULE) { +#if defined(nginx_version) && nginx_version >= 1009011 + modules = cf->cycle->modules; +#else + modules = ngx_modules; +#endif + for (i = 0; modules[i]; i++) { + if (modules[i]->type != NGX_RTMP_MODULE) { continue; } - module = ngx_modules[i]->ctx; + module = modules[i]->ctx; if (module->create_app_conf) { - ctx->app_conf[ngx_modules[i]->ctx_index] = + ctx->app_conf[modules[i]->ctx_index] = module->create_app_conf(cf); - if (ctx->app_conf[ngx_modules[i]->ctx_index] == NULL) { + if (ctx->app_conf[modules[i]->ctx_index] == NULL) { return NGX_CONF_ERROR; } } @@ -489,6 +501,7 @@ ngx_rtmp_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) ngx_str_t *value; ngx_url_t u; ngx_uint_t i, m; + ngx_module_t **modules; struct sockaddr *sa; ngx_rtmp_listen_t *ls; struct sockaddr_in *sin; @@ -571,8 +584,13 @@ ngx_rtmp_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) ls->wildcard = u.wildcard; ls->ctx = cf->ctx; - for (m = 0; ngx_modules[m]; m++) { - if (ngx_modules[m]->type != NGX_RTMP_MODULE) { +#if defined(nginx_version) && nginx_version >= 1009011 + modules = cf->cycle->modules; +#else + modules = ngx_modules; +#endif + for (m = 0; modules[m]; m++) { + if (modules[m]->type != NGX_RTMP_MODULE) { continue; } } diff --git a/ngx_rtmp_record_module.c b/ngx_rtmp_record_module.c index b884b2a..9b09d63 100644 --- a/ngx_rtmp_record_module.c +++ b/ngx_rtmp_record_module.c @@ -1222,6 +1222,7 @@ ngx_rtmp_record_recorder(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) ngx_int_t i; ngx_str_t *value; ngx_conf_t save; + ngx_module_t **modules; ngx_rtmp_module_t *module; ngx_rtmp_core_app_conf_t *cacf, **pcacf, *rcacf; ngx_rtmp_record_app_conf_t *racf, **pracf, *rracf; @@ -1248,17 +1249,22 @@ ngx_rtmp_record_recorder(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) return NGX_CONF_ERROR; } - for (i = 0; ngx_modules[i]; i++) { - if (ngx_modules[i]->type != NGX_RTMP_MODULE) { +#if defined(nginx_version) && nginx_version >= 1009011 + modules = cf->cycle->modules; +#else + modules = ngx_modules; +#endif + for (i = 0; modules[i]; i++) { + if (modules[i]->type != NGX_RTMP_MODULE) { continue; } - module = ngx_modules[i]->ctx; + module = modules[i]->ctx; if (module->create_app_conf) { - ctx->app_conf[ngx_modules[i]->ctx_index] = + ctx->app_conf[modules[i]->ctx_index] = module->create_app_conf(cf); - if (ctx->app_conf[ngx_modules[i]->ctx_index] == NULL) { + if (ctx->app_conf[modules[i]->ctx_index] == NULL) { return NGX_CONF_ERROR; } }