| OLD | NEW |
| 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 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 return SR_SUCCESS; | 548 return SR_SUCCESS; |
| 549 } | 549 } |
| 550 | 550 |
| 551 ssl_write_needs_read_ = false; | 551 ssl_write_needs_read_ = false; |
| 552 | 552 |
| 553 int code = SSL_write(ssl_, data, checked_cast<int>(data_len)); | 553 int code = SSL_write(ssl_, data, checked_cast<int>(data_len)); |
| 554 int ssl_error = SSL_get_error(ssl_, code); | 554 int ssl_error = SSL_get_error(ssl_, code); |
| 555 switch (ssl_error) { | 555 switch (ssl_error) { |
| 556 case SSL_ERROR_NONE: | 556 case SSL_ERROR_NONE: |
| 557 LOG(LS_VERBOSE) << " -- success"; | 557 LOG(LS_VERBOSE) << " -- success"; |
| 558 RTC_DCHECK(0 < code && static_cast<unsigned>(code) <= data_len); | 558 RTC_DCHECK_GT(code, 0); |
| 559 RTC_DCHECK_LE(code, data_len); |
| 559 if (written) | 560 if (written) |
| 560 *written = code; | 561 *written = code; |
| 561 return SR_SUCCESS; | 562 return SR_SUCCESS; |
| 562 case SSL_ERROR_WANT_READ: | 563 case SSL_ERROR_WANT_READ: |
| 563 LOG(LS_VERBOSE) << " -- error want read"; | 564 LOG(LS_VERBOSE) << " -- error want read"; |
| 564 ssl_write_needs_read_ = true; | 565 ssl_write_needs_read_ = true; |
| 565 return SR_BLOCK; | 566 return SR_BLOCK; |
| 566 case SSL_ERROR_WANT_WRITE: | 567 case SSL_ERROR_WANT_WRITE: |
| 567 LOG(LS_VERBOSE) << " -- error want write"; | 568 LOG(LS_VERBOSE) << " -- error want write"; |
| 568 return SR_BLOCK; | 569 return SR_BLOCK; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 return SR_SUCCESS; | 613 return SR_SUCCESS; |
| 613 } | 614 } |
| 614 | 615 |
| 615 ssl_read_needs_write_ = false; | 616 ssl_read_needs_write_ = false; |
| 616 | 617 |
| 617 int code = SSL_read(ssl_, data, checked_cast<int>(data_len)); | 618 int code = SSL_read(ssl_, data, checked_cast<int>(data_len)); |
| 618 int ssl_error = SSL_get_error(ssl_, code); | 619 int ssl_error = SSL_get_error(ssl_, code); |
| 619 switch (ssl_error) { | 620 switch (ssl_error) { |
| 620 case SSL_ERROR_NONE: | 621 case SSL_ERROR_NONE: |
| 621 LOG(LS_VERBOSE) << " -- success"; | 622 LOG(LS_VERBOSE) << " -- success"; |
| 622 RTC_DCHECK(0 < code && static_cast<unsigned>(code) <= data_len); | 623 RTC_DCHECK_GT(code, 0); |
| 624 RTC_DCHECK_LE(code, data_len); |
| 623 if (read) | 625 if (read) |
| 624 *read = code; | 626 *read = code; |
| 625 | 627 |
| 626 if (ssl_mode_ == SSL_MODE_DTLS) { | 628 if (ssl_mode_ == SSL_MODE_DTLS) { |
| 627 // Enforce atomic reads -- this is a short read | 629 // Enforce atomic reads -- this is a short read |
| 628 unsigned int pending = SSL_pending(ssl_); | 630 unsigned int pending = SSL_pending(ssl_); |
| 629 | 631 |
| 630 if (pending) { | 632 if (pending) { |
| 631 LOG(LS_INFO) << " -- short DTLS read. flushing"; | 633 LOG(LS_INFO) << " -- short DTLS read. flushing"; |
| 632 FlushInput(pending); | 634 FlushInput(pending); |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1210 } | 1212 } |
| 1211 | 1213 |
| 1212 return false; | 1214 return false; |
| 1213 } | 1215 } |
| 1214 | 1216 |
| 1215 void OpenSSLStreamAdapter::enable_time_callback_for_testing() { | 1217 void OpenSSLStreamAdapter::enable_time_callback_for_testing() { |
| 1216 g_use_time_callback_for_testing = true; | 1218 g_use_time_callback_for_testing = true; |
| 1217 } | 1219 } |
| 1218 | 1220 |
| 1219 } // namespace rtc | 1221 } // namespace rtc |
| OLD | NEW |