Browse Source

Added try-catch when closing DataChannel and Track on destruction

Paul-Louis Ageneau 1 year ago
parent
commit
11a1493690
3 changed files with 11 additions and 11 deletions
  1. 1 7
      src/datachannel.cpp
  2. 5 2
      src/impl/datachannel.cpp
  3. 5 2
      src/impl/track.cpp

+ 1 - 7
src/datachannel.cpp

@@ -26,13 +26,7 @@ DataChannel::DataChannel(impl_ptr<impl::DataChannel> impl)
     : CheshireCat<impl::DataChannel>(impl),
       Channel(std::dynamic_pointer_cast<impl::Channel>(impl)) {}
 
-DataChannel::~DataChannel() {
-	try {
-		close();
-	} catch (const std::exception &e) {
-		PLOG_ERROR << e.what();
-	}
-}
+DataChannel::~DataChannel() {}
 
 void DataChannel::close() { return impl()->close(); }
 

+ 5 - 2
src/impl/datachannel.cpp

@@ -79,8 +79,11 @@ DataChannel::DataChannel(weak_ptr<PeerConnection> pc, string label, string proto
 
 DataChannel::~DataChannel() {
 	PLOG_VERBOSE << "Destroying DataChannel";
-
-	close();
+	try {
+		close();
+	} catch (const std::exception &e) {
+		PLOG_ERROR << e.what();
+	}
 }
 
 void DataChannel::close() {

+ 5 - 2
src/impl/track.cpp

@@ -30,8 +30,11 @@ Track::Track(weak_ptr<PeerConnection> pc, Description::Media description)
 
 Track::~Track() {
 	PLOG_VERBOSE << "Destroying Track";
-
-	close();
+	try {
+		close();
+	} catch (const std::exception &e) {
+		PLOG_ERROR << e.what();
+	}
 }
 
 string Track::mid() const {