summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/network/connection.cpp13
-rw-r--r--src/network/connection.h19
2 files changed, 8 insertions, 24 deletions
diff --git a/src/network/connection.cpp b/src/network/connection.cpp
index f7452d8e4..02c0aa165 100644
--- a/src/network/connection.cpp
+++ b/src/network/connection.cpp
@@ -2167,12 +2167,12 @@ void ConnectionReceiveThread::receive()
throw InvalidIncomingDataException("Channel doesn't exist");
}
- /* preserve original peer_id for later usage */
- u16 packet_peer_id = peer_id;
-
/* Try to identify peer by sender address (may happen on join) */
if (peer_id == PEER_ID_INEXISTENT) {
peer_id = m_connection->lookupPeer(sender);
+ // We do not have to remind the peer of its
+ // peer id as the CONTROLTYPE_SET_PEER_ID
+ // command was sent reliably.
}
/* The peer was not found in our lists. Add it. */
@@ -2214,11 +2214,6 @@ void ConnectionReceiveThread::receive()
}
}
-
- /* mark peer as seen with id */
- if (!(packet_peer_id == PEER_ID_INEXISTENT))
- peer->setSentWithID();
-
peer->ResetTimeout();
Channel *channel = 0;
@@ -2756,7 +2751,7 @@ u16 Connection::lookupPeer(Address& sender)
for(; j != m_peers.end(); ++j)
{
Peer *peer = j->second;
- if (peer->isActive())
+ if (peer->isPendingDeletion())
continue;
Address tocheck;
diff --git a/src/network/connection.h b/src/network/connection.h
index fe2c9819d..5ee53b9d4 100644
--- a/src/network/connection.h
+++ b/src/network/connection.h
@@ -663,8 +663,7 @@ class Peer {
m_last_rtt(-1.0),
m_usage(0),
m_timeout_counter(0.0),
- m_last_timeout_check(porting::getTimeMs()),
- m_has_sent_with_id(false)
+ m_last_timeout_check(porting::getTimeMs())
{
m_rtt.avg_rtt = -1.0;
m_rtt.jitter_avg = -1.0;
@@ -687,21 +686,16 @@ class Peer {
virtual void PutReliableSendCommand(ConnectionCommand &c,
unsigned int max_packet_size) {};
- virtual bool isActive() { return false; };
-
virtual bool getAddress(MTProtocols type, Address& toset) = 0;
+ bool isPendingDeletion()
+ { MutexAutoLock lock(m_exclusive_access_mutex); return m_pending_deletion; };
+
void ResetTimeout()
{MutexAutoLock lock(m_exclusive_access_mutex); m_timeout_counter=0.0; };
bool isTimedOut(float timeout);
- void setSentWithID()
- { MutexAutoLock lock(m_exclusive_access_mutex); m_has_sent_with_id = true; };
-
- bool hasSentWithID()
- { MutexAutoLock lock(m_exclusive_access_mutex); return m_has_sent_with_id; };
-
unsigned int m_increment_packets_remaining;
unsigned int m_increment_bytes_remaining;
@@ -776,8 +770,6 @@ class Peer {
float m_timeout_counter;
u32 m_last_timeout_check;
-
- bool m_has_sent_with_id;
};
class UDPPeer : public Peer
@@ -795,9 +787,6 @@ public:
void PutReliableSendCommand(ConnectionCommand &c,
unsigned int max_packet_size);
- bool isActive()
- { return ((hasSentWithID()) && (!m_pending_deletion)); };
-
bool getAddress(MTProtocols type, Address& toset);
void setNonLegacyPeer();