Fix bug 574524: DtlsTransportChannel crashes after SSL closes remotely

When remote side closes, opensslstreamadapter could return SR_EOS which will not trigger upper layer to clean up what's left in the StreamInterfaceChannel. The result of this is when there are more packets coming in, the Write on the StreamInterfaceChannel will overflow the buffer.

The fix here is that when receiving the remote side close signal, we also close the underneath StreamInterfaceChannel which will clean up the queue to prevent overflow.

BUG=574524
TBR=pthatcher@webrtc.org

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

Cr-Commit-Position: refs/heads/master@{#11751}
diff --git a/webrtc/base/bufferqueue.cc b/webrtc/base/bufferqueue.cc
index 9c2324e..6e5439d 100644
--- a/webrtc/base/bufferqueue.cc
+++ b/webrtc/base/bufferqueue.cc
@@ -34,6 +34,14 @@
   return queue_.size();
 }
 
+void BufferQueue::Clear() {
+  CritScope cs(&crit_);
+  while (!queue_.empty()) {
+    free_list_.push_back(queue_.front());
+    queue_.pop_front();
+  }
+}
+
 bool BufferQueue::ReadFront(void* buffer, size_t bytes, size_t* bytes_read) {
   CritScope cs(&crit_);
   if (queue_.empty()) {