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

Unified Diff: webrtc/p2p/base/dtlstransportchannel.cc

Issue 2970883005: Handle case where UDP packet contains multiple DTLS records. (Closed)
Patch Set: Feedback from Taylor. Created 3 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webrtc/p2p/base/dtlstransportchannel_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/dtlstransportchannel.cc
diff --git a/webrtc/p2p/base/dtlstransportchannel.cc b/webrtc/p2p/base/dtlstransportchannel.cc
index f5d658340baefacaf83494c48afa9f1d08f94fda..2a7988030e594ad776f0778fc1988846559618d1 100644
--- a/webrtc/p2p/base/dtlstransportchannel.cc
+++ b/webrtc/p2p/base/dtlstransportchannel.cc
@@ -537,20 +537,25 @@ void DtlsTransport::OnDtlsEvent(rtc::StreamInterface* dtls, int sig, int err) {
char buf[kMaxDtlsPacketLen];
size_t read;
int read_error;
- rtc::StreamResult ret = dtls_->Read(buf, sizeof(buf), &read, &read_error);
- if (ret == rtc::SR_SUCCESS) {
- SignalReadPacket(this, buf, read, rtc::CreatePacketTime(0), 0);
- } else if (ret == rtc::SR_EOS) {
- // Remote peer shut down the association with no error.
- LOG_J(LS_INFO, this) << "DTLS transport closed";
- set_writable(false);
- set_dtls_state(DTLS_TRANSPORT_CLOSED);
- } else if (ret == rtc::SR_ERROR) {
- // Remote peer shut down the association with an error.
- LOG_J(LS_INFO, this) << "DTLS transport error, code=" << read_error;
- set_writable(false);
- set_dtls_state(DTLS_TRANSPORT_FAILED);
- }
+ rtc::StreamResult ret;
+ // The underlying DTLS stream may have received multiple DTLS records in
+ // one packet, so read all of them.
+ do {
+ ret = dtls_->Read(buf, sizeof(buf), &read, &read_error);
+ if (ret == rtc::SR_SUCCESS) {
+ SignalReadPacket(this, buf, read, rtc::CreatePacketTime(0), 0);
+ } else if (ret == rtc::SR_EOS) {
+ // Remote peer shut down the association with no error.
+ LOG_J(LS_INFO, this) << "DTLS transport closed";
+ set_writable(false);
+ set_dtls_state(DTLS_TRANSPORT_CLOSED);
+ } else if (ret == rtc::SR_ERROR) {
+ // Remote peer shut down the association with an error.
+ LOG_J(LS_INFO, this) << "DTLS transport error, code=" << read_error;
+ set_writable(false);
+ set_dtls_state(DTLS_TRANSPORT_FAILED);
+ }
+ } while (ret == rtc::SR_SUCCESS);
}
if (sig & rtc::SE_CLOSE) {
RTC_DCHECK(sig == rtc::SE_CLOSE); // SE_CLOSE should be by itself.
« no previous file with comments | « no previous file | webrtc/p2p/base/dtlstransportchannel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698