avformat/tls_schannel: fix handling of EOF after avio changes
authorHendrik Leppkes <h.leppkes@gmail.com>
Wed, 18 Apr 2018 12:09:19 +0000 (14:09 +0200)
committerHendrik Leppkes <h.leppkes@gmail.com>
Thu, 19 Apr 2018 11:26:53 +0000 (13:26 +0200)
libavformat/tls_schannel.c

index 9a6e0c9..f41b007 100644 (file)
@@ -413,11 +413,13 @@ static int tls_read(URLContext *h, uint8_t *buf, int len)
 
         ret = ffurl_read(s->tcp, c->enc_buf + c->enc_buf_offset,
                          c->enc_buf_size - c->enc_buf_offset);
 
         ret = ffurl_read(s->tcp, c->enc_buf + c->enc_buf_offset,
                          c->enc_buf_size - c->enc_buf_offset);
-        if (ret < 0) {
+        if (ret == AVERROR_EOF) {
+            c->connection_closed = 1;
+            ret = 0;
+        } else if (ret < 0) {
             av_log(h, AV_LOG_ERROR, "Unable to read from socket\n");
             return ret;
             av_log(h, AV_LOG_ERROR, "Unable to read from socket\n");
             return ret;
-        } else if (ret == 0)
-            c->connection_closed = 1;
+        }
 
         c->enc_buf_offset += ret;
     }
 
         c->enc_buf_offset += ret;
     }
@@ -515,7 +517,7 @@ cleanup:
     if (ret == 0 && !c->connection_closed)
         ret = AVERROR(EAGAIN);
 
     if (ret == 0 && !c->connection_closed)
         ret = AVERROR(EAGAIN);
 
-    return ret < 0 ? ret : 0;
+    return ret < 0 ? ret : AVERROR_EOF;
 }
 
 static int tls_write(URLContext *h, const uint8_t *buf, int len)
 }
 
 static int tls_write(URLContext *h, const uint8_t *buf, int len)