diff mbox

[FFmpeg-devel,v2,1/1] avformat/http: fix for zero window size issue

Message ID 1520413624-12394-1-git-send-email-rpatagar@akamai.com
State New
Headers show

Commit Message

Patagar, Ravindra March 7, 2018, 9:07 a.m. UTC
From: Ravindra <rpatagar@akamai.com>

When http persistent conenction is enabled for streaming, TCP window size
reduces consistently and reaches zero
---
 libavformat/http.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff mbox

Patch

diff --git a/libavformat/http.c b/libavformat/http.c
index 344fd60..a93fa54 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -1611,6 +1611,18 @@  static int http_write(URLContext *h, const uint8_t *buf, int size)
     return size;
 }
 
+static int http_read_response(URLContext *h) {
+    HTTPContext *s = h->priv_data;
+    char buf[1024];
+    int ret;
+
+    /* dummy read in nonblocking mode to clear the receive buffer */
+    s->hd->flags |= AVIO_FLAG_NONBLOCK;
+    ret = ffurl_read(s->hd, buf, sizeof(buf));
+    s->hd->flags &= ~AVIO_FLAG_NONBLOCK;
+    return ret;
+}
+
 static int http_shutdown(URLContext *h, int flags)
 {
     int ret = 0;
@@ -1622,6 +1634,7 @@  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;
+        http_read_response(h);
         s->end_chunked_post = 1;
     }