Skip to content

Commit

Permalink
[dev] optimize the function ngx_http_flv_live_handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
winshining committed Mar 20, 2019
1 parent 42936f4 commit 4ae37e6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
19 changes: 4 additions & 15 deletions ngx_http_flv_live_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -986,8 +986,6 @@ ngx_http_flv_live_request(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
}

if (s->notify_connect) {
r->main->count++;

return NGX_OK;
}

Expand All @@ -1005,12 +1003,7 @@ ngx_http_flv_live_request(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
(ngx_int_t) v.duration, (ngx_int_t) v.reset,
(ngx_int_t) v.silent);

rc = ngx_rtmp_play(s, &v);
if (rc == NGX_OK && s->notify_play) {
r->main->count++;
}

return rc;
return ngx_rtmp_play(s, &v);
}


Expand Down Expand Up @@ -1143,8 +1136,6 @@ ngx_http_flv_live_play(ngx_rtmp_session_t *s, ngx_rtmp_play_t *v)
goto next;
}

r->main->count++;

#if (nginx_version >= 1013001)
/**
* when playing from pull, the downstream requests on the most
Expand All @@ -1160,8 +1151,6 @@ ngx_http_flv_live_play(ngx_rtmp_session_t *s, ngx_rtmp_play_t *v)
/* join stream as a subscriber */

if (ngx_http_flv_live_join(s, v->name, 0) == NGX_ERROR) {
r->main->count--;

return NGX_ERROR;
}

Expand All @@ -1182,8 +1171,6 @@ ngx_http_flv_live_close_http_request(ngx_rtmp_session_t *s)

r = s->data;
if (r && r->connection && !r->connection->destroyed) {
r->main->count--;

if (r->chunked) {
ngx_http_flv_live_send_tail(s);
}
Expand Down Expand Up @@ -2335,5 +2322,7 @@ ngx_http_flv_live_handler(ngx_http_request_t *r)
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}

return NGX_OK;
r->main->count++;

return NGX_DONE;
}
7 changes: 0 additions & 7 deletions ngx_rtmp_notify_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,6 @@ ngx_rtmp_notify_connect_handle(ngx_rtmp_session_t *s,
ngx_memzero(&p, sizeof(ngx_rtmp_play_t));
ngx_memcpy(p.name, s->stream.data, s->stream.len);
ngx_memcpy(p.args, s->args.data, s->args.len);
r->main->count--;

rc = ngx_rtmp_play(s, &p);
}
Expand Down Expand Up @@ -1122,18 +1121,12 @@ ngx_rtmp_notify_play_handle(ngx_rtmp_session_t *s,
ngx_rtmp_relay_target_t target;
ngx_url_t *u;
ngx_rtmp_notify_app_conf_t *nacf;
ngx_http_request_t *r;
u_char name[NGX_RTMP_MAX_NAME];

static ngx_str_t location = ngx_string("location");

if (s->notify_play) {
s->notify_play = 0;

r = s->data;
if (r) {
r->main->count--;
}
}

rc = ngx_rtmp_notify_parse_http_retcode(s, in);
Expand Down

0 comments on commit 4ae37e6

Please sign in to comment.