提交 c24dbb29 authored 作者: Nazar Mokrynskyi's avatar Nazar Mokrynskyi

Minor cleanup

上级 6868bd27
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
/* Static. */ /* Static. */
static constexpr size_t CheckerInterval{ 10u }; // In ms. static constexpr size_t CheckerInterval{ 10u }; // In ms.
static std::mutex globalSyncMutex; static std::mutex GlobalSyncMutex;
static size_t globalInstances = 0; static size_t GlobalInstances{ 0u };
/* Static methods for usrsctp global callbacks. */ /* Static methods for usrsctp global callbacks. */
...@@ -65,42 +65,38 @@ void DepUsrSCTP::ClassInit() ...@@ -65,42 +65,38 @@ void DepUsrSCTP::ClassInit()
MS_DEBUG_TAG(info, "usrsctp"); MS_DEBUG_TAG(info, "usrsctp");
{ std::lock_guard<std::mutex> lock(GlobalSyncMutex);
std::lock_guard<std::mutex> lock(globalSyncMutex);
if (globalInstances == 0) if (GlobalInstances == 0)
{ {
usrsctp_init_nothreads(0, onSendSctpData, sctpDebug); usrsctp_init_nothreads(0, onSendSctpData, sctpDebug);
// Disable explicit congestion notifications (ecn). // Disable explicit congestion notifications (ecn).
usrsctp_sysctl_set_sctp_ecn_enable(0); usrsctp_sysctl_set_sctp_ecn_enable(0);
#ifdef SCTP_DEBUG #ifdef SCTP_DEBUG
usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_ALL); usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_ALL);
#endif #endif
}
++globalInstances;
} }
++GlobalInstances;
} }
void DepUsrSCTP::ClassDestroy() void DepUsrSCTP::ClassDestroy()
{ {
MS_TRACE(); MS_TRACE();
{ std::lock_guard<std::mutex> lock(GlobalSyncMutex);
std::lock_guard<std::mutex> lock(globalSyncMutex); --GlobalInstances;
--globalInstances;
if (globalInstances == 0) if (GlobalInstances == 0)
{ {
usrsctp_finish(); usrsctp_finish();
numSctpAssociations = 0u; numSctpAssociations = 0u;
nextSctpAssociationId = 0u; nextSctpAssociationId = 0u;
DepUsrSCTP::mapIdSctpAssociation.clear(); DepUsrSCTP::mapIdSctpAssociation.clear();
}
} }
} }
...@@ -126,7 +122,7 @@ uintptr_t DepUsrSCTP::GetNextSctpAssociationId() ...@@ -126,7 +122,7 @@ uintptr_t DepUsrSCTP::GetNextSctpAssociationId()
{ {
MS_TRACE(); MS_TRACE();
std::lock_guard<std::mutex> lock(globalSyncMutex); std::lock_guard<std::mutex> lock(GlobalSyncMutex);
// NOTE: usrsctp_connect() fails with a value of 0. // NOTE: usrsctp_connect() fails with a value of 0.
if (DepUsrSCTP::nextSctpAssociationId == 0u) if (DepUsrSCTP::nextSctpAssociationId == 0u)
...@@ -150,7 +146,7 @@ void DepUsrSCTP::RegisterSctpAssociation(RTC::SctpAssociation* sctpAssociation) ...@@ -150,7 +146,7 @@ void DepUsrSCTP::RegisterSctpAssociation(RTC::SctpAssociation* sctpAssociation)
{ {
MS_TRACE(); MS_TRACE();
std::lock_guard<std::mutex> lock(globalSyncMutex); std::lock_guard<std::mutex> lock(GlobalSyncMutex);
MS_ASSERT(DepUsrSCTP::checker != nullptr, "Checker not created"); MS_ASSERT(DepUsrSCTP::checker != nullptr, "Checker not created");
...@@ -170,7 +166,7 @@ void DepUsrSCTP::DeregisterSctpAssociation(RTC::SctpAssociation* sctpAssociation ...@@ -170,7 +166,7 @@ void DepUsrSCTP::DeregisterSctpAssociation(RTC::SctpAssociation* sctpAssociation
{ {
MS_TRACE(); MS_TRACE();
std::lock_guard<std::mutex> lock(globalSyncMutex); std::lock_guard<std::mutex> lock(GlobalSyncMutex);
MS_ASSERT(DepUsrSCTP::checker != nullptr, "Checker not created"); MS_ASSERT(DepUsrSCTP::checker != nullptr, "Checker not created");
...@@ -187,7 +183,7 @@ RTC::SctpAssociation* DepUsrSCTP::RetrieveSctpAssociation(uintptr_t id) ...@@ -187,7 +183,7 @@ RTC::SctpAssociation* DepUsrSCTP::RetrieveSctpAssociation(uintptr_t id)
{ {
MS_TRACE(); MS_TRACE();
std::lock_guard<std::mutex> lock(globalSyncMutex); std::lock_guard<std::mutex> lock(GlobalSyncMutex);
auto it = DepUsrSCTP::mapIdSctpAssociation.find(id); auto it = DepUsrSCTP::mapIdSctpAssociation.find(id);
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论