Преглед изворни кода

Check for non-destroyed objects in rtcCleanup()

Paul-Louis Ageneau пре 3 година
родитељ
комит
c24a2fe81f
1 измењених фајлова са 10 додато и 2 уклоњено
  1. 10 2
      src/capi.cpp

+ 10 - 2
src/capi.cpp

@@ -135,21 +135,25 @@ void eraseTrack(int tr) {
 	userPointerMap.erase(tr);
 }
 
-void eraseAll() {
+size_t eraseAll() {
 	std::lock_guard lock(mutex);
+	size_t count = dataChannelMap.size() + trackMap.size() + peerConnectionMap.size();
 	dataChannelMap.clear();
 	trackMap.clear();
 	peerConnectionMap.clear();
 #if RTC_ENABLE_MEDIA
+	count += rtcpChainableHandlerMap.size() + rtcpSrReporterMap.size() + rtpConfigMap.size();
 	rtcpChainableHandlerMap.clear();
 	rtcpSrReporterMap.clear();
 	rtpConfigMap.clear();
 #endif
 #if RTC_ENABLE_WEBSOCKET
+	count += webSocketMap.size() + webSocketServerMap.size();
 	webSocketMap.clear();
 	webSocketServerMap.clear();
 #endif
 	userPointerMap.clear();
+	return count;
 }
 
 shared_ptr<Channel> getChannel(int id) {
@@ -1365,7 +1369,11 @@ void rtcPreload() {
 
 void rtcCleanup() {
 	try {
-		eraseAll();
+		size_t count = eraseAll();
+		if(count != 0) {
+			PLOG_INFO << count << " objects were not properly destroyed before cleanup";
+		}
+
 		if(rtc::Cleanup().wait_for(10s) == std::future_status::timeout)
 			throw std::runtime_error("Cleanup timeout (possible deadlock or undestructible object)");