Add calls to SteamNetworkingGlobalLock::AssertHeldByCurrentThread()

This commit is contained in:
Fletcher Dunn
2020-12-21 10:04:44 -08:00
parent 232d18b7eb
commit a45ea8a37f
3 changed files with 20 additions and 0 deletions
@@ -82,6 +82,8 @@ CSteamNetworkingMessages::CSteamNetworkingMessages( CSteamNetworkingSockets &ste
bool CSteamNetworkingMessages::BInit()
{
SteamNetworkingGlobalLock::AssertHeldByCurrentThread();
// Create listen socket
{
SteamNetworkingConfigValue_t opt[2];
@@ -682,6 +682,8 @@ ESteamNetworkingAvailability CSteamNetworkingSockets::InitAuthentication()
void CSteamNetworkingSockets::CheckAuthenticationPrerequisites( SteamNetworkingMicroseconds usecNow )
{
#ifdef STEAMNETWORKINGSOCKETS_CAN_REQUEST_CERT
SteamNetworkingGlobalLock::AssertHeldByCurrentThread();
// Check if we're in flight already.
bool bInFlight = BCertRequestInFlight();
@@ -783,6 +785,7 @@ void CSteamNetworkingSockets::DeduceAuthenticationStatus()
void CSteamNetworkingSockets::SetAuthenticationStatus( const SteamNetAuthenticationStatus_t &newStatus )
{
SteamNetworkingGlobalLock::AssertHeldByCurrentThread();
// No change?
bool bStatusChanged = newStatus.m_eAvail != m_AuthenticationStatus.m_eAvail;
@@ -811,6 +814,8 @@ void CSteamNetworkingSockets::SetAuthenticationStatus( const SteamNetAuthenticat
#ifdef STEAMNETWORKINGSOCKETS_CAN_REQUEST_CERT
void CSteamNetworkingSockets::AsyncCertRequestFinished()
{
SteamNetworkingGlobalLock::AssertHeldByCurrentThread( "AsyncCertRequestFinished" );
Assert( m_msgSignedCert.has_cert() );
SetCertStatus( k_ESteamNetworkingAvailability_Current, "OK" );
@@ -824,6 +829,8 @@ void CSteamNetworkingSockets::AsyncCertRequestFinished()
void CSteamNetworkingSockets::CertRequestFailed( ESteamNetworkingAvailability eCertAvail, ESteamNetConnectionEnd nConnectionEndReason, const char *pszMsg )
{
SteamNetworkingGlobalLock::AssertHeldByCurrentThread( "CertRequestFailed" );
SpewWarning( "Cert request for %s failed with reason code %d. %s\n", SteamNetworkingIdentityRender( InternalGetIdentity() ).c_str(), nConnectionEndReason, pszMsg );
// Schedule a retry. Note that if we have active connections that need for a cert,
@@ -315,10 +315,14 @@ CSteamNetworkPollGroup::CSteamNetworkPollGroup( CSteamNetworkingSockets *pInterf
: m_pSteamNetworkingSocketsInterface( pInterface )
, m_hPollGroupSelf( k_HSteamListenSocket_Invalid )
{
// Object creation is rare; to keep things simple we require the global lock
SteamNetworkingGlobalLock::AssertHeldByCurrentThread();
}
CSteamNetworkPollGroup::~CSteamNetworkPollGroup()
{
// Object deletion is rare; to keep things simple we require the global lock
SteamNetworkingGlobalLock::AssertHeldByCurrentThread();
FOR_EACH_VEC_BACK( m_vecConnections, i )
{
CSteamNetworkConnectionBase *pConn = m_vecConnections[i];
@@ -369,6 +373,9 @@ CSteamNetworkPollGroup::~CSteamNetworkPollGroup()
void CSteamNetworkPollGroup::AssignHandleAndAddToGlobalTable()
{
// Object creation is rare; to keep things simple we require the global lock
SteamNetworkingGlobalLock::AssertHeldByCurrentThread();
Assert( m_hPollGroupSelf == k_HSteamNetPollGroup_Invalid );
// We actually don't do map "lookups". We assume the number of listen sockets
@@ -411,6 +418,7 @@ CSteamNetworkListenSocketBase::CSteamNetworkListenSocketBase( CSteamNetworkingSo
CSteamNetworkListenSocketBase::~CSteamNetworkListenSocketBase()
{
SteamNetworkingGlobalLock::AssertHeldByCurrentThread();
AssertMsg( m_mapChildConnections.Count() == 0, "Destroy() not used properly" );
// Remove us from global table, if we're in it
@@ -433,6 +441,8 @@ CSteamNetworkListenSocketBase::~CSteamNetworkListenSocketBase()
bool CSteamNetworkListenSocketBase::BInitListenSocketCommon( int nOptions, const SteamNetworkingConfigValue_t *pOptions, SteamDatagramErrMsg &errMsg )
{
SteamNetworkingGlobalLock::AssertHeldByCurrentThread();
Assert( m_hListenSocketSelf == k_HSteamListenSocket_Invalid );
// Assign us a handle, and add us to the global table
@@ -494,6 +504,7 @@ bool CSteamNetworkListenSocketBase::BInitListenSocketCommon( int nOptions, const
void CSteamNetworkListenSocketBase::Destroy()
{
SteamNetworkingGlobalLock::AssertHeldByCurrentThread();
// Destroy all child connections
FOR_EACH_HASHMAP( m_mapChildConnections, h )