1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-01 17:38:41 +00:00

Warn if max_packets_per_iteration reduced

This commit is contained in:
sfan5 2024-08-18 22:06:48 +02:00
parent 1380bf9b88
commit 8972c80d7d
2 changed files with 15 additions and 6 deletions

View file

@ -59,14 +59,24 @@ static inline u8 readChannel(const u8 *packetdata)
/* Connection Threads */
/******************************************************************************/
#define MPPI_SETTING "max_packets_per_iteration"
ConnectionSendThread::ConnectionSendThread(unsigned int max_packet_size,
float timeout) :
Thread("ConnectionSend"),
m_max_packet_size(max_packet_size),
m_timeout(timeout),
m_max_data_packets_per_iteration(g_settings->getU16("max_packets_per_iteration"))
m_max_data_packets_per_iteration(g_settings->getU16(MPPI_SETTING))
{
SANITY_CHECK(m_max_data_packets_per_iteration > 1);
auto &mppi = m_max_data_packets_per_iteration;
mppi = MYMAX(mppi, 1);
const auto mppi_default = Settings::getLayer(SL_DEFAULTS)->getU16(MPPI_SETTING);
if (mppi < mppi_default) {
warningstream << "You are running the network code with a non-default "
"configuration (" MPPI_SETTING "=" << mppi << "). "
"This is not recommended in production." << std::endl;
}
}
void *ConnectionSendThread::run()
@ -769,7 +779,7 @@ void ConnectionSendThread::sendPackets(float dtime, u32 peer_packet_quota)
}
}
if (peer_packet_quota > 0) {
if (peer_packet_quota > 0 && !stopRequested()) {
for (session_t peerId : peerIds) {
PeerHelper peer = m_connection->getPeerNoEx(peerId);
if (!peer)