mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 10:03:45 +01:00
Use fixed, lower timeout for half-open connections
This commit is contained in:
parent
2587302987
commit
7acb14f7a1
@ -653,6 +653,7 @@ protected:
|
|||||||
|
|
||||||
void setResendTimeout(float timeout)
|
void setResendTimeout(float timeout)
|
||||||
{ MutexAutoLock lock(m_exclusive_access_mutex); resend_timeout = timeout; }
|
{ MutexAutoLock lock(m_exclusive_access_mutex); resend_timeout = timeout; }
|
||||||
|
|
||||||
bool Ping(float dtime,SharedBuffer<u8>& data);
|
bool Ping(float dtime,SharedBuffer<u8>& data);
|
||||||
|
|
||||||
Channel channels[CHANNEL_COUNT];
|
Channel channels[CHANNEL_COUNT];
|
||||||
|
@ -193,7 +193,11 @@ void ConnectionSendThread::runTimeouts(float dtime)
|
|||||||
/*
|
/*
|
||||||
Check peer timeout
|
Check peer timeout
|
||||||
*/
|
*/
|
||||||
if (peer->isTimedOut(m_timeout)) {
|
// When the connection is half-open give the peer less time.
|
||||||
|
// Note that this time is also fixed since the timeout is not reset in half-open state.
|
||||||
|
const float peer_timeout = peer->isHalfOpen() ?
|
||||||
|
MYMAX(5.0f, m_timeout / 4) : m_timeout;
|
||||||
|
if (peer->isTimedOut(peer_timeout)) {
|
||||||
infostream << m_connection->getDesc()
|
infostream << m_connection->getDesc()
|
||||||
<< "RunTimeouts(): Peer " << peer->id
|
<< "RunTimeouts(): Peer " << peer->id
|
||||||
<< " has timed out."
|
<< " has timed out."
|
||||||
@ -208,7 +212,7 @@ void ConnectionSendThread::runTimeouts(float dtime)
|
|||||||
for (Channel &channel : udpPeer->channels) {
|
for (Channel &channel : udpPeer->channels) {
|
||||||
|
|
||||||
// Remove timed out incomplete unreliable split packets
|
// Remove timed out incomplete unreliable split packets
|
||||||
channel.incoming_splits.removeUnreliableTimedOuts(dtime, m_timeout);
|
channel.incoming_splits.removeUnreliableTimedOuts(dtime, peer_timeout);
|
||||||
|
|
||||||
// Increment reliable packet times
|
// Increment reliable packet times
|
||||||
channel.outgoing_reliables_sent.incrementTimeouts(dtime);
|
channel.outgoing_reliables_sent.incrementTimeouts(dtime);
|
||||||
@ -243,11 +247,7 @@ void ConnectionSendThread::runTimeouts(float dtime)
|
|||||||
if (udpPeer->Ping(dtime, data)) {
|
if (udpPeer->Ping(dtime, data)) {
|
||||||
LOG(dout_con << m_connection->getDesc()
|
LOG(dout_con << m_connection->getDesc()
|
||||||
<< "Sending ping for peer_id: " << udpPeer->id << std::endl);
|
<< "Sending ping for peer_id: " << udpPeer->id << std::endl);
|
||||||
/* this may fail if there ain't a sequence number left */
|
rawSendAsPacket(udpPeer->id, 0, data, true);
|
||||||
if (!rawSendAsPacket(udpPeer->id, 0, data, true)) {
|
|
||||||
//retrigger with reduced ping interval
|
|
||||||
udpPeer->Ping(4.0, data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
udpPeer->RunCommandQueues(m_max_packet_size,
|
udpPeer->RunCommandQueues(m_max_packet_size,
|
||||||
@ -1002,10 +1002,11 @@ void ConnectionReceiveThread::receive(SharedBuffer<u8> &packetdata,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (knew_peer_id)
|
if (knew_peer_id) {
|
||||||
peer->SetFullyOpen();
|
peer->SetFullyOpen();
|
||||||
|
// Setup phase has a fixed timeout
|
||||||
peer->ResetTimeout();
|
peer->ResetTimeout();
|
||||||
|
}
|
||||||
|
|
||||||
Channel *channel = nullptr;
|
Channel *channel = nullptr;
|
||||||
if (dynamic_cast<UDPPeer *>(&peer)) {
|
if (dynamic_cast<UDPPeer *>(&peer)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user