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

Unified Diff: talk/app/webrtc/peerconnection.cc

Issue 1492383002: Free SCTP data channels asynchronously in PeerConnection. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Adding unit test. Created 5 years 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 | talk/app/webrtc/peerconnectionendtoend_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: talk/app/webrtc/peerconnection.cc
diff --git a/talk/app/webrtc/peerconnection.cc b/talk/app/webrtc/peerconnection.cc
index f0db1397aa7941612612ea3be8cb010b0b09c854..8d04ae629068f367b5daeecfe6c03398f97692aa 100644
--- a/talk/app/webrtc/peerconnection.cc
+++ b/talk/app/webrtc/peerconnection.cc
@@ -106,6 +106,7 @@ enum {
MSG_SET_SESSIONDESCRIPTION_FAILED,
MSG_CREATE_SESSIONDESCRIPTION_FAILED,
MSG_GETSTATS,
+ MSG_DELETE,
};
struct SetSessionDescriptionMsg : public rtc::MessageData {
@@ -595,6 +596,8 @@ PeerConnection::PeerConnection(PeerConnectionFactory* factory)
PeerConnection::~PeerConnection() {
RTC_DCHECK(signaling_thread()->IsCurrent());
+ // Finish any pending deletions.
+ signaling_thread()->Clear(this, MSG_DELETE, nullptr);
// Need to detach RTP senders/receivers from WebRtcSession,
// since it's about to be destroyed.
for (const auto& sender : senders_) {
@@ -1313,6 +1316,10 @@ void PeerConnection::OnMessage(rtc::Message* msg) {
delete param;
break;
}
+ case MSG_DELETE: {
+ delete msg->pdata;
+ break;
+ }
default:
RTC_DCHECK(false && "Not implemented");
break;
@@ -1900,6 +1907,11 @@ void PeerConnection::OnSctpDataChannelClosed(DataChannel* channel) {
if (channel->id() >= 0) {
sid_allocator_.ReleaseSid(channel->id());
}
+ // Since this method is triggered by a signal from the DataChannel,
+ // we can't free it directly here; we need to free it asynchronously.
+ signaling_thread()->Post(
+ this, MSG_DELETE,
+ new rtc::TypedMessageData<rtc::scoped_refptr<DataChannel>>(channel));
sctp_data_channels_.erase(it);
return;
}
« no previous file with comments | « no previous file | talk/app/webrtc/peerconnectionendtoend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698