[FFmpeg-cvslog] Merge commit 'eb061ad6fd0e3cea7cf7cfbff0749bc90dd7d888'
James Almer
git at videolan.org
Fri Nov 3 04:43:45 EET 2017
ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Thu Nov 2 23:39:28 2017 -0300| [2805c8dcfc3b7d3701a72cef06af5e477c6c0cdb] | committer: James Almer
Merge commit 'eb061ad6fd0e3cea7cf7cfbff0749bc90dd7d888'
* commit 'eb061ad6fd0e3cea7cf7cfbff0749bc90dd7d888':
tls_gnutls: Readd support for nonblocking operation
Merged-by: James Almer <jamrial at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2805c8dcfc3b7d3701a72cef06af5e477c6c0cdb
---
libavformat/tls_gnutls.c | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/libavformat/tls_gnutls.c b/libavformat/tls_gnutls.c
index 7adb4eed56..0cef9575ec 100644
--- a/libavformat/tls_gnutls.c
+++ b/libavformat/tls_gnutls.c
@@ -75,6 +75,7 @@ static int print_tls_error(URLContext *h, int ret)
{
switch (ret) {
case GNUTLS_E_AGAIN:
+ return AVERROR(EAGAIN);
case GNUTLS_E_INTERRUPTED:
#ifdef GNUTLS_E_PREMATURE_TERMINATION
case GNUTLS_E_PREMATURE_TERMINATION:
@@ -114,7 +115,10 @@ static ssize_t gnutls_url_pull(gnutls_transport_ptr_t transport,
return ret;
if (ret == AVERROR_EXIT)
return 0;
- errno = EIO;
+ if (ret == AVERROR(EAGAIN))
+ errno = EAGAIN;
+ else
+ errno = EIO;
return -1;
}
@@ -127,7 +131,10 @@ static ssize_t gnutls_url_push(gnutls_transport_ptr_t transport,
return ret;
if (ret == AVERROR_EXIT)
return 0;
- errno = EIO;
+ if (ret == AVERROR(EAGAIN))
+ errno = EAGAIN;
+ else
+ errno = EIO;
return -1;
}
@@ -223,7 +230,11 @@ fail:
static int tls_read(URLContext *h, uint8_t *buf, int size)
{
TLSContext *c = h->priv_data;
- int ret = gnutls_record_recv(c->session, buf, size);
+ int ret;
+ // Set or clear the AVIO_FLAG_NONBLOCK on c->tls_shared.tcp
+ c->tls_shared.tcp->flags &= ~AVIO_FLAG_NONBLOCK;
+ c->tls_shared.tcp->flags |= h->flags & AVIO_FLAG_NONBLOCK;
+ ret = gnutls_record_recv(c->session, buf, size);
if (ret > 0)
return ret;
if (ret == 0)
@@ -234,7 +245,11 @@ static int tls_read(URLContext *h, uint8_t *buf, int size)
static int tls_write(URLContext *h, const uint8_t *buf, int size)
{
TLSContext *c = h->priv_data;
- int ret = gnutls_record_send(c->session, buf, size);
+ int ret;
+ // Set or clear the AVIO_FLAG_NONBLOCK on c->tls_shared.tcp
+ c->tls_shared.tcp->flags &= ~AVIO_FLAG_NONBLOCK;
+ c->tls_shared.tcp->flags |= h->flags & AVIO_FLAG_NONBLOCK;
+ ret = gnutls_record_send(c->session, buf, size);
if (ret > 0)
return ret;
if (ret == 0)
======================================================================
diff --cc libavformat/tls_gnutls.c
index 7adb4eed56,7bfe02deb0..0cef9575ec
--- a/libavformat/tls_gnutls.c
+++ b/libavformat/tls_gnutls.c
@@@ -75,10 -61,8 +75,11 @@@ static int print_tls_error(URLContext *
{
switch (ret) {
case GNUTLS_E_AGAIN:
+ return AVERROR(EAGAIN);
case GNUTLS_E_INTERRUPTED:
+#ifdef GNUTLS_E_PREMATURE_TERMINATION
+ case GNUTLS_E_PREMATURE_TERMINATION:
+#endif
break;
case GNUTLS_E_WARNING_ALERT_RECEIVED:
av_log(h, AV_LOG_WARNING, "%s\n", gnutls_strerror(ret));
More information about the ffmpeg-cvslog
mailing list