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

Unified Diff: webrtc/base/virtualsocketserver.cc

Issue 2915243002: Fixing SSL error that occurs when underlying socket is blocked. (Closed)
Patch Set: Send an additional message while socket is blocked. Created 3 years, 7 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
« webrtc/base/openssladapter.cc ('K') | « webrtc/base/ssladapter_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/virtualsocketserver.cc
diff --git a/webrtc/base/virtualsocketserver.cc b/webrtc/base/virtualsocketserver.cc
index 9ba6a2f7fa655a4042f865f1296351a829fdc7db..cfb4eb294b673dc97b041a8e3a98505855e0d64f 100644
--- a/webrtc/base/virtualsocketserver.cc
+++ b/webrtc/base/virtualsocketserver.cc
@@ -56,6 +56,7 @@ enum {
MSG_ID_ADDRESS_BOUND,
MSG_ID_CONNECT,
MSG_ID_DISCONNECT,
+ MSG_ID_SIGNALREADEVENT,
};
// Packets are passed between sockets as messages. We copy the data just like
@@ -303,6 +304,14 @@ int VirtualSocket::RecvFrom(void* pv,
delete packet;
}
+ // To behave like a real socket, SignalReadEvent should fire in the next
+ // message loop pass if there's still data buffered.
+ if (!recv_buffer_.empty()) {
+ // Clear the message so it doesn't end up posted multiple times.
+ server_->msg_queue_->Clear(this, MSG_ID_SIGNALREADEVENT);
+ server_->msg_queue_->Post(RTC_FROM_HERE, this, MSG_ID_SIGNALREADEVENT);
+ }
+
if (SOCK_STREAM == type_) {
bool was_full = (recv_buffer_size_ == server_->recv_buffer_capacity_);
recv_buffer_size_ -= data_read;
@@ -421,6 +430,10 @@ void VirtualSocket::OnMessage(Message* pmsg) {
}
} else if (pmsg->message_id == MSG_ID_ADDRESS_BOUND) {
SignalAddressReady(this, GetLocalAddress());
+ } else if (pmsg->message_id == MSG_ID_SIGNALREADEVENT) {
+ if (!recv_buffer_.empty()) {
+ SignalReadEvent(this);
+ }
} else {
RTC_NOTREACHED();
}
« webrtc/base/openssladapter.cc ('K') | « webrtc/base/ssladapter_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698