Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/brpc/socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2049,7 +2049,12 @@ int Socket::SSLHandshake(int fd, bool server_mode) {
}

_ssl_state = SSL_CONNECTED;
AddBIOBuffer(_ssl_session, fd, FLAGS_ssl_bio_buffer_size);
// Adding a BIO layer requires calling BIO_flush manually after SSL_write,
// which could trigger EAGAIN for large packets. However, it's very tedious
// to handle EAGAIN from both SSL_write and BIO_flush under current implementation.
// Also, BIO is a bit outdated for modern TCP as it already contains buffering.
// We decide to disable BIO.
// AddBIOBuffer(_ssl_session, fd, FLAGS_ssl_bio_buffer_size);
return 0;
}

Expand Down
21 changes: 11 additions & 10 deletions src/butil/iobuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -929,16 +929,17 @@ ssize_t IOBuf::cut_multiple_into_SSL_channel(SSL* ssl, IOBuf* const* pieces,
}

#ifndef USE_MESALINK
// Flush remaining data inside the BIO buffer layer
BIO* wbio = SSL_get_wbio(ssl);
if (BIO_wpending(wbio) > 0) {
int rc = BIO_flush(wbio);
if (rc <= 0 && BIO_fd_non_fatal_error(errno) == 0) {
// Fatal error during BIO_flush
*ssl_error = SSL_ERROR_SYSCALL;
return rc;
}
}
// BIO is disabled for now (see socket.cpp) and the following implementation is
// NOT correct since it doesn't handle the EAGAIN event of BIO_flush
// BIO* wbio = SSL_get_wbio(ssl);
// if (BIO_wpending(wbio) > 0) {
// int rc = BIO_flush(wbio);
// if (rc <= 0 && BIO_fd_non_fatal_error(errno) == 0) {
// // Fatal error during BIO_flush
// *ssl_error = SSL_ERROR_SYSCALL;
// return rc;
// }
// }
#else
int rc = SSL_flush(ssl);
if (rc <= 0) {
Expand Down
Loading