Skip to content

Commit e68add6

Browse files
committed
fixed http handlers stat/control
1 parent 612fc4d commit e68add6

File tree

2 files changed

+23
-28
lines changed

2 files changed

+23
-28
lines changed

ngx_rtmp_control_module.c

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "ngx_rtmp_record_module.h"
1212

1313

14-
static ngx_int_t ngx_rtmp_control_postconfiguration(ngx_conf_t *cf);
14+
static char *ngx_rtmp_control(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
1515
static void * ngx_rtmp_control_create_loc_conf(ngx_conf_t *cf);
1616
static char * ngx_rtmp_control_merge_loc_conf(ngx_conf_t *cf,
1717
void *parent, void *child);
@@ -52,7 +52,7 @@ static ngx_command_t ngx_rtmp_control_commands[] = {
5252

5353
{ ngx_string("rtmp_control"),
5454
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
55-
ngx_conf_set_bitmask_slot,
55+
ngx_rtmp_control,
5656
NGX_HTTP_LOC_CONF_OFFSET,
5757
offsetof(ngx_rtmp_control_loc_conf_t, control),
5858
ngx_rtmp_control_masks },
@@ -63,7 +63,7 @@ static ngx_command_t ngx_rtmp_control_commands[] = {
6363

6464
static ngx_http_module_t ngx_rtmp_control_module_ctx = {
6565
NULL, /* preconfiguration */
66-
ngx_rtmp_control_postconfiguration, /* postconfiguration */
66+
NULL, /* postconfiguration */
6767

6868
NULL, /* create main configuration */
6969
NULL, /* init main configuration */
@@ -511,19 +511,13 @@ ngx_rtmp_control_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
511511
}
512512

513513

514-
static ngx_int_t
515-
ngx_rtmp_control_postconfiguration(ngx_conf_t *cf)
514+
static char *
515+
ngx_rtmp_control(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
516516
{
517-
ngx_http_handler_pt *h;
518-
ngx_http_core_main_conf_t *cmcf;
519-
520-
cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
517+
ngx_http_core_loc_conf_t *clcf;
521518

522-
h = ngx_array_push(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers);
523-
if (h == NULL) {
524-
return NGX_ERROR;
525-
}
526-
*h = ngx_rtmp_control_handler;
519+
clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
520+
clcf->handler = ngx_rtmp_control_handler;
527521

528-
return NGX_OK;
529-
}
522+
return ngx_conf_set_bitmask_slot(cf, cmd, conf);
523+
}

ngx_rtmp_stat_module.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "ngx_rtmp_codec_module.h"
1212

1313

14+
static char *ngx_rtmp_stat(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
1415
static ngx_int_t ngx_rtmp_stat_postconfiguration(ngx_conf_t *cf);
1516
static void * ngx_rtmp_stat_create_loc_conf(ngx_conf_t *cf);
1617
static char * ngx_rtmp_stat_merge_loc_conf(ngx_conf_t *cf,
@@ -49,7 +50,7 @@ static ngx_command_t ngx_rtmp_stat_commands[] = {
4950

5051
{ ngx_string("rtmp_stat"),
5152
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
52-
ngx_conf_set_bitmask_slot,
53+
ngx_rtmp_stat,
5354
NGX_HTTP_LOC_CONF_OFFSET,
5455
offsetof(ngx_rtmp_stat_loc_conf_t, stat),
5556
ngx_rtmp_stat_masks },
@@ -622,22 +623,22 @@ ngx_rtmp_stat_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
622623
}
623624

624625

625-
static ngx_int_t
626-
ngx_rtmp_stat_postconfiguration(ngx_conf_t *cf)
626+
static char *
627+
ngx_rtmp_stat(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
627628
{
628-
ngx_http_handler_pt *h;
629-
ngx_http_core_main_conf_t *cmcf;
629+
ngx_http_core_loc_conf_t *clcf;
630630

631-
cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
631+
clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
632+
clcf->handler = ngx_rtmp_stat_handler;
632633

633-
h = ngx_array_push(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers);
634-
if (h == NULL) {
635-
return NGX_ERROR;
636-
}
637-
*h = ngx_rtmp_stat_handler;
634+
return ngx_conf_set_bitmask_slot(cf, cmd, conf);
635+
}
638636

637+
638+
static ngx_int_t
639+
ngx_rtmp_stat_postconfiguration(ngx_conf_t *cf)
640+
{
639641
start_time = ngx_cached_time->sec;
640642

641643
return NGX_OK;
642644
}
643-

0 commit comments

Comments
 (0)