Fix DTLS packet boundary handling in SSLStreamAdapterTests.

The tests were not honoring packet boundaries, thus causing failures
in tests with dropped/broken packets. This CL fixes this and also
re-enables the tests.

R=torbjorng@webrtc.org,pthatcher@webrtc.org,tommi@webrtc.org,juberti@webrtc.org
BUG=webrtc:5005,webrtc:5188

Review URL: https://codereview.webrtc.org/1440193002

Cr-Commit-Position: refs/heads/master@{#10709}
This commit is contained in:
jbauch
2015-11-19 05:17:58 -08:00
committed by Commit bot
parent 87097a8be5
commit e488a0dbe4
3 changed files with 190 additions and 85 deletions

View File

@ -38,19 +38,19 @@ bool BufferQueue::ReadFront(void* buffer, size_t bytes, size_t* bytes_read) {
return false;
}
bool was_writable = queue_.size() < capacity_;
Buffer* packet = queue_.front();
queue_.pop_front();
size_t next_packet_size = packet->size();
if (bytes > next_packet_size) {
bytes = next_packet_size;
}
bytes = std::min(bytes, packet->size());
memcpy(buffer, packet->data(), bytes);
if (bytes_read) {
*bytes_read = bytes;
}
free_list_.push_back(packet);
if (!was_writable) {
NotifyWritableForTest();
}
return true;
}
@ -61,6 +61,7 @@ bool BufferQueue::WriteBack(const void* buffer, size_t bytes,
return false;
}
bool was_readable = !queue_.empty();
Buffer* packet;
if (!free_list_.empty()) {
packet = free_list_.back();
@ -74,6 +75,9 @@ bool BufferQueue::WriteBack(const void* buffer, size_t bytes,
*bytes_written = bytes;
}
queue_.push_back(packet);
if (!was_readable) {
NotifyReadableForTest();
}
return true;
}