Netplay: More logging for server and client thread main loops.
This commit is contained in:
parent
bfe0940bbd
commit
0ccf24b0c5
|
@ -1581,6 +1581,8 @@ void NetPlayClient::SendAsync(sf::Packet&& packet, const u8 channel_id)
|
||||||
// called from ---NETPLAY--- thread
|
// called from ---NETPLAY--- thread
|
||||||
void NetPlayClient::ThreadFunc()
|
void NetPlayClient::ThreadFunc()
|
||||||
{
|
{
|
||||||
|
INFO_LOG_FMT(NETPLAY, "NetPlayClient starting.");
|
||||||
|
|
||||||
Common::QoSSession qos_session;
|
Common::QoSSession qos_session;
|
||||||
if (Config::Get(Config::NETPLAY_ENABLE_QOS))
|
if (Config::Get(Config::NETPLAY_ENABLE_QOS))
|
||||||
{
|
{
|
||||||
|
@ -1606,10 +1608,12 @@ void NetPlayClient::ThreadFunc()
|
||||||
net = enet_host_service(m_client, &netEvent, 250);
|
net = enet_host_service(m_client, &netEvent, 250);
|
||||||
while (!m_async_queue.Empty())
|
while (!m_async_queue.Empty())
|
||||||
{
|
{
|
||||||
|
INFO_LOG_FMT(NETPLAY, "Processing async queue event.");
|
||||||
{
|
{
|
||||||
auto& e = m_async_queue.Front();
|
auto& e = m_async_queue.Front();
|
||||||
Send(e.packet, e.channel_id);
|
Send(e.packet, e.channel_id);
|
||||||
}
|
}
|
||||||
|
INFO_LOG_FMT(NETPLAY, "Processing async queue event done.");
|
||||||
m_async_queue.Pop();
|
m_async_queue.Pop();
|
||||||
}
|
}
|
||||||
if (net > 0)
|
if (net > 0)
|
||||||
|
@ -1617,13 +1621,20 @@ void NetPlayClient::ThreadFunc()
|
||||||
sf::Packet rpac;
|
sf::Packet rpac;
|
||||||
switch (netEvent.type)
|
switch (netEvent.type)
|
||||||
{
|
{
|
||||||
|
case ENET_EVENT_TYPE_CONNECT:
|
||||||
|
INFO_LOG_FMT(NETPLAY, "enet_host_service: connect event");
|
||||||
|
break;
|
||||||
case ENET_EVENT_TYPE_RECEIVE:
|
case ENET_EVENT_TYPE_RECEIVE:
|
||||||
|
INFO_LOG_FMT(NETPLAY, "enet_host_service: receive event");
|
||||||
|
|
||||||
rpac.append(netEvent.packet->data, netEvent.packet->dataLength);
|
rpac.append(netEvent.packet->data, netEvent.packet->dataLength);
|
||||||
OnData(rpac);
|
OnData(rpac);
|
||||||
|
|
||||||
enet_packet_destroy(netEvent.packet);
|
enet_packet_destroy(netEvent.packet);
|
||||||
break;
|
break;
|
||||||
case ENET_EVENT_TYPE_DISCONNECT:
|
case ENET_EVENT_TYPE_DISCONNECT:
|
||||||
|
INFO_LOG_FMT(NETPLAY, "enet_host_service: disconnect event");
|
||||||
|
|
||||||
m_dialog->OnConnectionLost();
|
m_dialog->OnConnectionLost();
|
||||||
|
|
||||||
if (m_is_running.IsSet())
|
if (m_is_running.IsSet())
|
||||||
|
@ -1631,11 +1642,22 @@ void NetPlayClient::ThreadFunc()
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
ERROR_LOG_FMT(NETPLAY, "enet_host_service: unknown event type: {}", int(netEvent.type));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (net == 0)
|
||||||
|
{
|
||||||
|
INFO_LOG_FMT(NETPLAY, "enet_host_service: no event occurred");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ERROR_LOG_FMT(NETPLAY, "enet_host_service error: {}", net);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INFO_LOG_FMT(NETPLAY, "NetPlayClient shutting down.");
|
||||||
|
|
||||||
Disconnect();
|
Disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -270,8 +270,10 @@ void NetPlayServer::ThreadFunc()
|
||||||
net = enet_host_service(m_server, &netEvent, 1000);
|
net = enet_host_service(m_server, &netEvent, 1000);
|
||||||
while (!m_async_queue.Empty())
|
while (!m_async_queue.Empty())
|
||||||
{
|
{
|
||||||
|
INFO_LOG_FMT(NETPLAY, "Processing async queue event.");
|
||||||
{
|
{
|
||||||
std::lock_guard lkp(m_crit.players);
|
std::lock_guard lkp(m_crit.players);
|
||||||
|
INFO_LOG_FMT(NETPLAY, "Locked player mutex.");
|
||||||
auto& e = m_async_queue.Front();
|
auto& e = m_async_queue.Front();
|
||||||
if (e.target_mode == TargetMode::Only)
|
if (e.target_mode == TargetMode::Only)
|
||||||
{
|
{
|
||||||
|
@ -283,6 +285,7 @@ void NetPlayServer::ThreadFunc()
|
||||||
SendToClients(e.packet, e.target_pid, e.channel_id);
|
SendToClients(e.packet, e.target_pid, e.channel_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
INFO_LOG_FMT(NETPLAY, "Processing async queue event done.");
|
||||||
m_async_queue.Pop();
|
m_async_queue.Pop();
|
||||||
}
|
}
|
||||||
if (net > 0)
|
if (net > 0)
|
||||||
|
@ -299,6 +302,8 @@ void NetPlayServer::ThreadFunc()
|
||||||
break;
|
break;
|
||||||
case ENET_EVENT_TYPE_RECEIVE:
|
case ENET_EVENT_TYPE_RECEIVE:
|
||||||
{
|
{
|
||||||
|
INFO_LOG_FMT(NETPLAY, "enet_host_service: receive event");
|
||||||
|
|
||||||
sf::Packet rpac;
|
sf::Packet rpac;
|
||||||
rpac.append(netEvent.packet->data, netEvent.packet->dataLength);
|
rpac.append(netEvent.packet->data, netEvent.packet->dataLength);
|
||||||
|
|
||||||
|
@ -341,16 +346,26 @@ void NetPlayServer::ThreadFunc()
|
||||||
|
|
||||||
ClearPeerPlayerId(netEvent.peer);
|
ClearPeerPlayerId(netEvent.peer);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
INFO_LOG_FMT(NETPLAY, "successfully handled packet from client {}", client.pid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
enet_packet_destroy(netEvent.packet);
|
enet_packet_destroy(netEvent.packet);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ENET_EVENT_TYPE_DISCONNECT:
|
case ENET_EVENT_TYPE_DISCONNECT:
|
||||||
{
|
{
|
||||||
|
INFO_LOG_FMT(NETPLAY, "enet_host_service: disconnect event");
|
||||||
|
|
||||||
std::lock_guard lkg(m_crit.game);
|
std::lock_guard lkg(m_crit.game);
|
||||||
if (!netEvent.peer->data)
|
if (!netEvent.peer->data)
|
||||||
|
{
|
||||||
|
ERROR_LOG_FMT(NETPLAY, "enet_host_service: no peer data");
|
||||||
break;
|
break;
|
||||||
auto it = m_players.find(*PeerPlayerId(netEvent.peer));
|
}
|
||||||
|
const auto player_id = *PeerPlayerId(netEvent.peer);
|
||||||
|
auto it = m_players.find(player_id);
|
||||||
if (it != m_players.end())
|
if (it != m_players.end())
|
||||||
{
|
{
|
||||||
Client& client = it->second;
|
Client& client = it->second;
|
||||||
|
@ -359,12 +374,25 @@ void NetPlayServer::ThreadFunc()
|
||||||
|
|
||||||
ClearPeerPlayerId(netEvent.peer);
|
ClearPeerPlayerId(netEvent.peer);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ERROR_LOG_FMT(NETPLAY, "Invalid player {} to disconnect.", player_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
ERROR_LOG_FMT(NETPLAY, "enet_host_service: unknown event type: {}", int(netEvent.type));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (net == 0)
|
||||||
|
{
|
||||||
|
INFO_LOG_FMT(NETPLAY, "enet_host_service: no event occurred");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ERROR_LOG_FMT(NETPLAY, "enet_host_service error: {}", net);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO_LOG_FMT(NETPLAY, "NetPlayServer shutting down.");
|
INFO_LOG_FMT(NETPLAY, "NetPlayServer shutting down.");
|
||||||
|
|
Loading…
Reference in New Issue