@@ -351,6 +351,7 @@ ngx_http_flv_live_send_header(ngx_rtmp_session_t *s)
351
351
ngx_str_t chunked_flv_header ;
352
352
ngx_str_t consec_flv_header ;
353
353
u_char chunked_flv_header_data [18 ];
354
+ ngx_flag_t connection_header ;
354
355
355
356
/**
356
357
* |F|L|V|ver|00000101|header_size|0|0|0|0|, ngx_http_flv_module.c
@@ -365,6 +366,9 @@ ngx_http_flv_live_send_header(ngx_rtmp_session_t *s)
365
366
ngx_str_set (& r -> headers_out .content_type , "video/x-flv" );
366
367
367
368
/* fill HTTP header 'Connection' according to headers_in */
369
+ r -> keepalive = 0 ;
370
+
371
+ connection_header = 0 ;
368
372
part = & r -> headers_in .headers .part ;
369
373
header = part -> elts ;
370
374
@@ -384,18 +388,21 @@ ngx_http_flv_live_send_header(ngx_rtmp_session_t *s)
384
388
}
385
389
386
390
if (ngx_strcasecmp (header [i ].key .data , (u_char * ) "connection" ) == 0 ) {
391
+ connection_header = 1 ;
387
392
if (ngx_strcasecmp (header [i ].value .data , (u_char * ) "keep-alive" )
388
393
== 0 )
389
394
{
390
395
r -> keepalive = 1 ;
391
- } else {
392
- r -> keepalive = 0 ;
393
396
}
394
397
395
398
break ;
396
399
}
397
400
}
398
401
402
+ if (!connection_header && r -> http_version == NGX_HTTP_VERSION_11 ) {
403
+ r -> keepalive = 1 ;
404
+ }
405
+
399
406
live_ctx = ngx_rtmp_get_module_ctx (s , ngx_rtmp_live_module );
400
407
if (live_ctx && !live_ctx -> active ) {
401
408
ngx_log_error (NGX_LOG_ERR , s -> connection -> log , 0 ,
@@ -991,9 +998,7 @@ ngx_http_flv_live_request(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
991
998
992
999
ngx_http_flv_live_play_handler (& ctx -> play );
993
1000
994
- if (r -> main -> blocked == 0 ) {
995
- r -> main -> blocked ++ ;
996
- }
1001
+ r -> main -> count ++ ;
997
1002
998
1003
return ctx -> error ? NGX_ERROR : NGX_OK ;
999
1004
}
@@ -1171,9 +1176,7 @@ ngx_http_flv_live_play(ngx_rtmp_session_t *s, ngx_rtmp_play_t *v)
1171
1176
goto next ;
1172
1177
}
1173
1178
1174
- if (r -> main -> blocked == 0 ) {
1175
- r -> main -> blocked ++ ;
1176
- }
1179
+ r -> main -> count ++ ;
1177
1180
1178
1181
#if (nginx_version >= 1013001 )
1179
1182
/**
@@ -1194,9 +1197,7 @@ ngx_http_flv_live_play(ngx_rtmp_session_t *s, ngx_rtmp_play_t *v)
1194
1197
/* join stream as a subscriber */
1195
1198
1196
1199
if (ngx_http_flv_live_join (s , v -> name , 0 ) == NGX_ERROR ) {
1197
- if (r -> main -> blocked ) {
1198
- r -> main -> blocked -- ;
1199
- }
1200
+ r -> main -> count -- ;
1200
1201
1201
1202
return NGX_ERROR ;
1202
1203
}
@@ -1224,9 +1225,7 @@ ngx_http_flv_live_close_http_request(ngx_rtmp_session_t *s)
1224
1225
1225
1226
r = s -> data ;
1226
1227
if (r && r -> connection && !r -> connection -> destroyed ) {
1227
- if (r -> main -> blocked ) {
1228
- r -> main -> blocked -- ;
1229
- }
1228
+ r -> main -> count -- ;
1230
1229
1231
1230
if (r -> chunked ) {
1232
1231
ngx_http_flv_live_send_tail (s );
@@ -1370,9 +1369,7 @@ ngx_http_flv_live_play_handler(ngx_event_t *ev)
1370
1369
(ngx_int_t ) v .duration , (ngx_int_t ) v .reset ,
1371
1370
(ngx_int_t ) v .silent );
1372
1371
1373
- if (r -> main -> blocked ) {
1374
- r -> blocked -- ;
1375
- }
1372
+ r -> main -> count -- ;
1376
1373
1377
1374
if (ngx_rtmp_play (s , & v ) != NGX_OK ) {
1378
1375
ctx -> error = 1 ;
0 commit comments