mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-28 20:53:54 +02:00
tls: Remove the nonblocking code
Since the underlying URLContext read functions are used, they handle interruption, without having to handle it at this level. Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
parent
d15eec4d6b
commit
d13b124eaf
@ -44,10 +44,9 @@ static ssize_t gnutls_url_pull(gnutls_transport_ptr_t transport,
|
|||||||
int ret = ffurl_read(h, buf, len);
|
int ret = ffurl_read(h, buf, len);
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
return ret;
|
return ret;
|
||||||
if (ret == AVERROR(EAGAIN))
|
if (ret == AVERROR_EXIT)
|
||||||
errno = EAGAIN;
|
return 0;
|
||||||
else
|
errno = EIO;
|
||||||
errno = EIO;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
static ssize_t gnutls_url_push(gnutls_transport_ptr_t transport,
|
static ssize_t gnutls_url_push(gnutls_transport_ptr_t transport,
|
||||||
@ -57,10 +56,9 @@ static ssize_t gnutls_url_push(gnutls_transport_ptr_t transport,
|
|||||||
int ret = ffurl_write(h, buf, len);
|
int ret = ffurl_write(h, buf, len);
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
return ret;
|
return ret;
|
||||||
if (ret == AVERROR(EAGAIN))
|
if (ret == AVERROR_EXIT)
|
||||||
errno = EAGAIN;
|
return 0;
|
||||||
else
|
errno = EIO;
|
||||||
errno = EIO;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#elif CONFIG_OPENSSL
|
#elif CONFIG_OPENSSL
|
||||||
@ -97,8 +95,8 @@ static int url_bio_bread(BIO *b, char *buf, int len)
|
|||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
return ret;
|
return ret;
|
||||||
BIO_clear_retry_flags(b);
|
BIO_clear_retry_flags(b);
|
||||||
if (ret == AVERROR(EAGAIN))
|
if (ret == AVERROR_EXIT)
|
||||||
BIO_set_retry_read(b);
|
return 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,8 +107,8 @@ static int url_bio_bwrite(BIO *b, const char *buf, int len)
|
|||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
return ret;
|
return ret;
|
||||||
BIO_clear_retry_flags(b);
|
BIO_clear_retry_flags(b);
|
||||||
if (ret == AVERROR(EAGAIN))
|
if (ret == AVERROR_EXIT)
|
||||||
BIO_set_retry_write(b);
|
return 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,16 +214,7 @@ static int do_tls_poll(URLContext *h, int ret)
|
|||||||
return AVERROR(EIO);
|
return AVERROR(EIO);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (h->flags & AVIO_FLAG_NONBLOCK)
|
return AVERROR(EIO);
|
||||||
return AVERROR(EAGAIN);
|
|
||||||
while (1) {
|
|
||||||
int n = poll(&p, 1, 100);
|
|
||||||
if (n > 0)
|
|
||||||
break;
|
|
||||||
if (ff_check_interrupt(&h->interrupt_callback))
|
|
||||||
return AVERROR(EINTR);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **options)
|
static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **options)
|
||||||
@ -314,7 +303,6 @@ static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **op
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
gnutls_credentials_set(c->session, GNUTLS_CRD_CERTIFICATE, c->cred);
|
gnutls_credentials_set(c->session, GNUTLS_CRD_CERTIFICATE, c->cred);
|
||||||
c->tcp->flags |= AVIO_FLAG_NONBLOCK;
|
|
||||||
gnutls_transport_set_pull_function(c->session, gnutls_url_pull);
|
gnutls_transport_set_pull_function(c->session, gnutls_url_pull);
|
||||||
gnutls_transport_set_push_function(c->session, gnutls_url_push);
|
gnutls_transport_set_push_function(c->session, gnutls_url_push);
|
||||||
gnutls_transport_set_ptr(c->session, c->tcp);
|
gnutls_transport_set_ptr(c->session, c->tcp);
|
||||||
@ -390,7 +378,6 @@ static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **op
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
bio = BIO_new(&url_bio_method);
|
bio = BIO_new(&url_bio_method);
|
||||||
c->tcp->flags |= AVIO_FLAG_NONBLOCK;
|
|
||||||
bio->ptr = c->tcp;
|
bio->ptr = c->tcp;
|
||||||
SSL_set_bio(c->ssl, bio, bio);
|
SSL_set_bio(c->ssl, bio, bio);
|
||||||
if (!c->listen && !numerichost)
|
if (!c->listen && !numerichost)
|
||||||
|
Loading…
Reference in New Issue
Block a user