[FFmpeg-devel] [PATCH 1/1] avformat/http: flushing tcp receive buffer when it is write only mode

Dixit, Vishwanath vdixit at akamai.com
Wed Apr 4 14:11:16 EEST 2018



On 3/28/18 11:00 AM, Steven Liu wrote:
>
>
>> On 28 Mar 2018, at 12:52, vdixit at akamai.com wrote:
>>
>> From: Vishwanath Dixit <vdixit at akamai.com>
>>
>> In write only mode, the TCP receive buffer keeps growing and eventually
>> becomes full. This results in zero tcp window size, which in turn causes
>> unwanted issues, like, terminated tcp connection. The issue is apparent
>> when http persistent connection is enabled in hls/dash streaming use
>> cases. To overcome this issue, the logic here reads and discards the data
>> from the tcp socket.
>> ---
>> libavformat/http.c | 7 +++++++
>> 1 file changed, 7 insertions(+)
>>
>> diff --git a/libavformat/http.c b/libavformat/http.c
>> index 983034f..e6d414b 100644
>> --- a/libavformat/http.c
>> +++ b/libavformat/http.c
>> @@ -1627,6 +1627,13 @@ static int http_shutdown(URLContext *h, int flags)
>>         ((flags & AVIO_FLAG_READ) && s->chunked_post && s->listen)) {
>>         ret = ffurl_write(s->hd, footer, sizeof(footer) - 1);
>>         ret = ret > 0 ? 0 : ret;
>> +        /* flush the receive buffer when it is write only mode */
>> +        if (!(flags & AVIO_FLAG_READ)) {
>> +            char buf[1024];
>> +            s->hd->flags |= AVIO_FLAG_NONBLOCK;
>> +            ffurl_read(s->hd, buf, sizeof(buf));
> ffurl_read have a int return value.
>
> 407 int ffurl_read(URLContext *h, unsigned char *buf, int size)
> 408 {
> 409     if (!(h->flags & AVIO_FLAG_READ))
> 410         return AVERROR(EIO);
> 411     return retry_transfer_wrapper(h, buf, size, 1, h->prot->url_read);
> 412 }
>
>
Thanks for the review comment. I have handled the return status of ffurl_read and have submitted a revised patch https://patchwork.ffmpeg.org/patch/8325/ 


>> +            s->hd->flags &= ~AVIO_FLAG_NONBLOCK;
>> +        }
>>         s->end_chunked_post = 1;
>>     }
>>
>> -- 
>> 1.9.1
>>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> Thanks
> Steven
>
>
>
>
>





More information about the ffmpeg-devel mailing list