From f6ccfb6fa1d05d3babc1bb20ca7003802f85f2f0 Mon Sep 17 00:00:00 2001 From: Roman Arutyunyan Date: Sat, 28 Apr 2012 21:36:07 +0400 Subject: [PATCH] added chunk size fix --- ngx_rtmp_handler.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/ngx_rtmp_handler.c b/ngx_rtmp_handler.c index 8e1dba0..1e5259a 100644 --- a/ngx_rtmp_handler.c +++ b/ngx_rtmp_handler.c @@ -204,7 +204,7 @@ ngx_rtmp_init_connection(ngx_connection_t *c) c->log->connection = c->number; c->log->handler = ngx_rtmp_log_error; c->log->data = ctx; - c->log->action = "sending client greeting line"; + c->log->action = NULL; c->log_error = NGX_ERROR_INFO; @@ -1138,6 +1138,7 @@ ngx_rtmp_set_chunk_size(ngx_rtmp_session_t *s, ngx_uint_t size) for ( ;; ) { bi = li->buf; bo = lo->buf; + if (bo->end - bo->last >= bi->last - bi->pos) { bo->last = ngx_cpymem(bo->last, bi->pos, bi->last - bi->pos); @@ -1147,17 +1148,15 @@ ngx_rtmp_set_chunk_size(ngx_rtmp_session_t *s, ngx_uint_t size) s->in_streams[n].in = lo; break; } - } else { - bo->last = ngx_cpymem(bo->last, bi->pos, - bo->end - bo->last); - bi->pos += (bo->end - bo->last); + continue; } - if (bo->last == bo->end) { - lo->next = ngx_rtmp_alloc_in_buf(s); - if (lo->next == NULL) { - return NGX_ERROR; - } - lo = lo->next; + + bi->pos += (ngx_cpymem(bo->last, bi->pos, + bo->end - bo->last) - bo->last); + lo->next = ngx_rtmp_alloc_in_buf(s); + lo = lo->next; + if (lo == NULL) { + return NGX_ERROR; } } }