Browse Source

Fixed Init critical section

Paul-Louis Ageneau 5 years ago
parent
commit
dd2967b0e1
1 changed files with 5 additions and 0 deletions
  1. 5 0
      src/init.cpp

+ 5 - 0
src/init.cpp

@@ -67,6 +67,8 @@ void Init::Cleanup() {
 }
 
 Init::Init() {
+	// Mutex is locked by Token() here
+
 #ifdef _WIN32
 	WSADATA wsaData;
 	if (WSAStartup(MAKEWORD(2, 2), &wsaData))
@@ -92,6 +94,9 @@ Init::Init() {
 }
 
 Init::~Init() {
+	// We need to lock Mutex ourselves
+	std::lock_guard lock(Mutex);
+
 	SctpTransport::Cleanup();
 	DtlsTransport::Cleanup();
 #if RTC_ENABLE_WEBSOCKET