Hi!
I've started integrating GNS into a pet project to analyze it, and the following felt wrong:
In ChatServer::OnSteamNetConnectionStatusChanged the code does the following:
case k_ESteamNetworkingConnectionState_ClosedByPeer:
case k_ESteamNetworkingConnectionState_ProblemDetectedLocally:
if ( pInfo->m_eOldState == k_ESteamNetworkingConnectionState_Connected )
{
m_mapClients.erase( itClient );
}
else
{
assert( pInfo->m_eOldState == k_ESteamNetworkingConnectionState_Connecting );
}
break;
However looking down in the same switch:
case k_ESteamNetworkingConnectionState_Connecting:
// Add them to the client list, using std::map wacky syntax
m_mapClients[ pInfo->m_hConn ];
What's weird here is that an entry in m_mapClients gets inserted after receiving the k_ESteamNetworkingConnectionState_Connecting message.
However upon disconnection, (i.e. _ClosedByPeer & _ProblemDetectedLocally) it assumes that if previous state was _Connecting then there should be no entry in m_mapClients.
This sounds contradictory.
I can think of the following cases:
- This is a bug. The code should always remove the entry from
m_mapClients
- This is a bug. The code has no way to know if the closure happened before or after GNS performed a callback with
_Connecting. We should first check if there is an entry in m_mapClients, and if there is one, remove it
- This is expected.
_ClosedByPeer / _ProblemDetectedLocally getting called after _Connecting but before _Connected means that GNS never got the chance to call our callback
I suspect this is likely a bug, which would make sense since the opportunity window for triggering it is ridiculously low (it needs to disconnect after _Connecting but before anything else, or perhaps due to how GNS works internally, that situation can't actually happen).
Hi!
I've started integrating GNS into a pet project to analyze it, and the following felt wrong:
In ChatServer::OnSteamNetConnectionStatusChanged the code does the following:
However looking down in the same switch:
What's weird here is that an entry in
m_mapClientsgets inserted after receiving thek_ESteamNetworkingConnectionState_Connectingmessage.However upon disconnection, (i.e.
_ClosedByPeer&_ProblemDetectedLocally) it assumes that if previous state was_Connectingthen there should be no entry inm_mapClients.This sounds contradictory.
I can think of the following cases:
m_mapClients_Connecting. We should first check if there is an entry inm_mapClients, and if there is one, remove it_ClosedByPeer/_ProblemDetectedLocallygetting called after_Connectingbut before_Connectedmeans that GNS never got the chance to call our callbackI suspect this is likely a bug, which would make sense since the opportunity window for triggering it is ridiculously low (it needs to disconnect after
_Connectingbut before anything else, or perhaps due to how GNS works internally, that situation can't actually happen).