1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

For #1657, fix the http read bug

This commit is contained in:
winlin 2020-11-06 19:53:37 +08:00
parent c3f23f4c23
commit 79655adea0
2 changed files with 35 additions and 29 deletions

View file

@ -681,6 +681,7 @@ srs_error_t SrsSslConnection::read(void* plaintext, size_t nn_plaintext, ssize_t
{
srs_error_t err = srs_success;
while (true) {
ssize_t nn = 0;
int nn_padding = BIO_ctrl_pending(bio_in);
if (nn_padding > 0) {
@ -705,9 +706,12 @@ srs_error_t SrsSslConnection::read(void* plaintext, size_t nn_plaintext, ssize_t
}
int r0 = SSL_read(ssl, plaintext, nn);
int r1 = SSL_get_error(ssl, r0);
int r2 = BIO_ctrl_pending(bio_in);
int r1 = SSL_get_error(ssl, r0); int r2 = BIO_ctrl_pending(bio_in);
if (r0 <= 0) {
// We try to read the cached data, but actually there is nothing, so try again.
if (nn_padding > 0 && r2 <= 0) {
continue;
}
return srs_error_new(ERROR_HTTPS_READ, "SSL_read r0=%d, r1=%d, r2=%d, padding=%d, size=%d",
r0, r1, r2, nn_padding, nn);
}
@ -716,6 +720,8 @@ srs_error_t SrsSslConnection::read(void* plaintext, size_t nn_plaintext, ssize_t
if (nread) {
*nread = r0;
}
break;
}
return err;
}

View file

@ -24,6 +24,6 @@
#ifndef SRS_CORE_VERSION4_HPP
#define SRS_CORE_VERSION4_HPP
#define SRS_VERSION4_REVISION 49
#define SRS_VERSION4_REVISION 50
#endif