Enable read-ahead on OpenSSL DTLS stream adapters.

Prevent multiple BIO reads when reading header and body but read from
internal OpenSSL buffer where possible.

BUG=chromium:447431
R=davidben@chromium.org, juberti@google.com

Review URL: https://webrtc-codereview.appspot.com/46319004

Cr-Commit-Position: refs/heads/master@{#9230}
This commit is contained in:
Joachim Bauch 2015-05-20 10:40:15 +02:00
parent 931e6583b2
commit 5ca688b3da

View File

@ -739,6 +739,12 @@ int OpenSSLStreamAdapter::BeginSSL() {
SSL_set_app_data(ssl_, this);
SSL_set_bio(ssl_, bio, bio); // the SSL object owns the bio now.
if (ssl_mode_ == SSL_MODE_DTLS) {
// Enable read-ahead for DTLS so whole packets are read from internal BIO
// before parsing.
// TODO(jbauch): Remove for BoringSSL when this is handled internally.
SSL_set_read_ahead(ssl_, 1);
}
SSL_set_mode(ssl_, SSL_MODE_ENABLE_PARTIAL_WRITE |
SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);