From e68add616c295408a2da04fc27d94a76920484b3 Mon Sep 17 00:00:00 2001 From: Roman Arutyunyan Date: Sat, 6 Apr 2013 19:01:20 +0400 Subject: [PATCH] fixed http handlers stat/control --- ngx_rtmp_control_module.c | 26 ++++++++++---------------- ngx_rtmp_stat_module.c | 27 ++++++++++++++------------- 2 files changed, 24 insertions(+), 29 deletions(-) diff --git a/ngx_rtmp_control_module.c b/ngx_rtmp_control_module.c index f76639e..97bf3e9 100644 --- a/ngx_rtmp_control_module.c +++ b/ngx_rtmp_control_module.c @@ -11,7 +11,7 @@ #include "ngx_rtmp_record_module.h" -static ngx_int_t ngx_rtmp_control_postconfiguration(ngx_conf_t *cf); +static char *ngx_rtmp_control(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); static void * ngx_rtmp_control_create_loc_conf(ngx_conf_t *cf); static char * ngx_rtmp_control_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child); @@ -52,7 +52,7 @@ static ngx_command_t ngx_rtmp_control_commands[] = { { ngx_string("rtmp_control"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, - ngx_conf_set_bitmask_slot, + ngx_rtmp_control, NGX_HTTP_LOC_CONF_OFFSET, offsetof(ngx_rtmp_control_loc_conf_t, control), ngx_rtmp_control_masks }, @@ -63,7 +63,7 @@ static ngx_command_t ngx_rtmp_control_commands[] = { static ngx_http_module_t ngx_rtmp_control_module_ctx = { NULL, /* preconfiguration */ - ngx_rtmp_control_postconfiguration, /* postconfiguration */ + NULL, /* postconfiguration */ NULL, /* create main configuration */ NULL, /* init main configuration */ @@ -511,19 +511,13 @@ ngx_rtmp_control_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) } -static ngx_int_t -ngx_rtmp_control_postconfiguration(ngx_conf_t *cf) +static char * +ngx_rtmp_control(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { - ngx_http_handler_pt *h; - ngx_http_core_main_conf_t *cmcf; + ngx_http_core_loc_conf_t *clcf; - cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); + clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); + clcf->handler = ngx_rtmp_control_handler; - h = ngx_array_push(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers); - if (h == NULL) { - return NGX_ERROR; - } - *h = ngx_rtmp_control_handler; - - return NGX_OK; -} + return ngx_conf_set_bitmask_slot(cf, cmd, conf); +} diff --git a/ngx_rtmp_stat_module.c b/ngx_rtmp_stat_module.c index c90a2c3..e4337ff 100644 --- a/ngx_rtmp_stat_module.c +++ b/ngx_rtmp_stat_module.c @@ -11,6 +11,7 @@ #include "ngx_rtmp_codec_module.h" +static char *ngx_rtmp_stat(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); static ngx_int_t ngx_rtmp_stat_postconfiguration(ngx_conf_t *cf); static void * ngx_rtmp_stat_create_loc_conf(ngx_conf_t *cf); static char * ngx_rtmp_stat_merge_loc_conf(ngx_conf_t *cf, @@ -49,7 +50,7 @@ static ngx_command_t ngx_rtmp_stat_commands[] = { { ngx_string("rtmp_stat"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, - ngx_conf_set_bitmask_slot, + ngx_rtmp_stat, NGX_HTTP_LOC_CONF_OFFSET, offsetof(ngx_rtmp_stat_loc_conf_t, stat), ngx_rtmp_stat_masks }, @@ -622,22 +623,22 @@ ngx_rtmp_stat_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) } +static char * +ngx_rtmp_stat(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) +{ + ngx_http_core_loc_conf_t *clcf; + + clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); + clcf->handler = ngx_rtmp_stat_handler; + + return ngx_conf_set_bitmask_slot(cf, cmd, conf); +} + + static ngx_int_t ngx_rtmp_stat_postconfiguration(ngx_conf_t *cf) { - ngx_http_handler_pt *h; - ngx_http_core_main_conf_t *cmcf; - - cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); - - h = ngx_array_push(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers); - if (h == NULL) { - return NGX_ERROR; - } - *h = ngx_rtmp_stat_handler; - start_time = ngx_cached_time->sec; return NGX_OK; } -