Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(986)

Side by Side Diff: webrtc/base/opensslstreamadapter.cc

Issue 2670113002: Pick the DTLS handshake timeout based on the ICE RTT estimate (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 void OpenSSLStreamAdapter::SetMode(SSLMode mode) { 516 void OpenSSLStreamAdapter::SetMode(SSLMode mode) {
517 RTC_DCHECK(state_ == SSL_NONE); 517 RTC_DCHECK(state_ == SSL_NONE);
518 ssl_mode_ = mode; 518 ssl_mode_ = mode;
519 } 519 }
520 520
521 void OpenSSLStreamAdapter::SetMaxProtocolVersion(SSLProtocolVersion version) { 521 void OpenSSLStreamAdapter::SetMaxProtocolVersion(SSLProtocolVersion version) {
522 RTC_DCHECK(ssl_ctx_ == NULL); 522 RTC_DCHECK(ssl_ctx_ == NULL);
523 ssl_max_version_ = version; 523 ssl_max_version_ = version;
524 } 524 }
525 525
526 void OpenSSLStreamAdapter::SetHandshakeTimeout(int timeout_ms) {
527 RTC_DCHECK(ssl_ctx_ == NULL);
Taylor Brandstetter 2017/02/02 18:07:41 Should leave a comment in the header file saying t
skvlad 2017/02/02 22:19:33 Done.
528 dtls_handshake_timeout_ms_ = timeout_ms;
529 }
530
526 // 531 //
527 // StreamInterface Implementation 532 // StreamInterface Implementation
528 // 533 //
529 534
530 StreamResult OpenSSLStreamAdapter::Write(const void* data, size_t data_len, 535 StreamResult OpenSSLStreamAdapter::Write(const void* data, size_t data_len,
531 size_t* written, int* error) { 536 size_t* written, int* error) {
532 LOG(LS_VERBOSE) << "OpenSSLStreamAdapter::Write(" << data_len << ")"; 537 LOG(LS_VERBOSE) << "OpenSSLStreamAdapter::Write(" << data_len << ")";
533 538
534 switch (state_) { 539 switch (state_) {
535 case SSL_NONE: 540 case SSL_NONE:
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 if (!ssl_) { 798 if (!ssl_) {
794 BIO_free(bio); 799 BIO_free(bio);
795 return -1; 800 return -1;
796 } 801 }
797 802
798 SSL_set_app_data(ssl_, this); 803 SSL_set_app_data(ssl_, this);
799 804
800 SSL_set_bio(ssl_, bio, bio); // the SSL object owns the bio now. 805 SSL_set_bio(ssl_, bio, bio); // the SSL object owns the bio now.
801 if (ssl_mode_ == SSL_MODE_DTLS) { 806 if (ssl_mode_ == SSL_MODE_DTLS) {
802 #ifdef OPENSSL_IS_BORINGSSL 807 #ifdef OPENSSL_IS_BORINGSSL
803 // Change the initial retransmission timer from 1 second to 50ms. 808 // Change the initial retransmission timer to the value selected to match
804 // This will likely result in some spurious retransmissions, but 809 // the connection RTT. This ensures fast connection setup without excessive
805 // it's useful for ensuring a timely handshake when there's packet 810 // bandwidth usage.
Taylor Brandstetter 2017/02/02 18:07:41 This comment is a little out of place here; this c
skvlad 2017/02/02 22:19:33 Acknowledged.
806 // loss. 811 DTLSv1_set_initial_timeout_duration(ssl_, dtls_handshake_timeout_ms_);
807 DTLSv1_set_initial_timeout_duration(ssl_, 50);
808 #else 812 #else
809 // Enable read-ahead for DTLS so whole packets are read from internal BIO 813 // Enable read-ahead for DTLS so whole packets are read from internal BIO
810 // before parsing. This is done internally by BoringSSL for DTLS. 814 // before parsing. This is done internally by BoringSSL for DTLS.
811 SSL_set_read_ahead(ssl_, 1); 815 SSL_set_read_ahead(ssl_, 1);
812 #endif 816 #endif
813 } 817 }
814 818
815 SSL_set_mode(ssl_, SSL_MODE_ENABLE_PARTIAL_WRITE | 819 SSL_set_mode(ssl_, SSL_MODE_ENABLE_PARTIAL_WRITE |
816 SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER); 820 SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
817 821
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 } 1231 }
1228 1232
1229 return false; 1233 return false;
1230 } 1234 }
1231 1235
1232 void OpenSSLStreamAdapter::enable_time_callback_for_testing() { 1236 void OpenSSLStreamAdapter::enable_time_callback_for_testing() {
1233 g_use_time_callback_for_testing = true; 1237 g_use_time_callback_for_testing = true;
1234 } 1238 }
1235 1239
1236 } // namespace rtc 1240 } // namespace rtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698