Permalink
Browse files

Improve Connection with threading and some kind of congestion control

  • Loading branch information...
1 parent b6fcbc5 commit 4b6138e69b65271b0e568f821a4d1bd285affedd @celeron55 committed Oct 20, 2011
Showing with 1,333 additions and 886 deletions.
  1. +1 −1 minetest.conf.example
  2. +8 −15 src/client.cpp
  3. +5 −5 src/client.h
  4. +1,021 −741 src/connection.cpp
  5. +209 −72 src/connection.h
  6. +1 −1 src/defaultsettings.cpp
  7. +2 −0 src/main.cpp
  8. +2 −0 src/map.cpp
  9. +29 −31 src/server.cpp
  10. +2 −2 src/server.h
  11. +11 −12 src/servercommand.cpp
  12. +42 −6 src/test.cpp
View
@@ -142,7 +142,7 @@
#active_object_send_range_blocks = 3
#active_block_range = 2
#max_simultaneous_block_sends_per_client = 2
-#max_simultaneous_block_sends_server_total = 2
+#max_simultaneous_block_sends_server_total = 8
#max_block_send_distance = 7
#max_block_generate_distance = 5
#time_send_interval = 20
View
@@ -246,7 +246,7 @@ void Client::connect(Address address)
{
DSTACK(__FUNCTION_NAME);
//JMutexAutoLock lock(m_con_mutex); //bulk comment-out
- m_con.setTimeoutMs(0);
+ m_con.SetTimeoutMs(0);
m_con.Connect(address);
}
@@ -563,8 +563,8 @@ void Client::step(float dtime)
counter = 0.0;
//JMutexAutoLock lock(m_con_mutex); //bulk comment-out
// connectedAndInitialized() is true, peer exists.
- con::Peer *peer = m_con.GetPeer(PEER_ID_SERVER);
- infostream<<"Client: avg_rtt="<<peer->avg_rtt<<std::endl;
+ float avg_rtt = m_con.GetPeerAvgRTT(PEER_ID_SERVER);
+ infostream<<"Client: avg_rtt="<<avg_rtt<<std::endl;
}
}
@@ -709,14 +709,6 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
return;
}
- con::Peer *peer;
- {
- //JMutexAutoLock lock(m_con_mutex); //bulk comment-out
- // All data is coming from the server
- // PeerNotFoundException is handled by caller.
- peer = m_con.GetPeer(PEER_ID_SERVER);
- }
-
u8 ser_version = m_server_ser_ver;
//infostream<<"Client received command="<<(int)command<<std::endl;
@@ -2168,9 +2160,10 @@ ClientEvent Client::getClientEvent()
float Client::getRTT(void)
{
- con::Peer *peer = m_con.GetPeerNoEx(PEER_ID_SERVER);
- if(!peer)
- return 0.0;
- return peer->avg_rtt;
+ try{
+ return m_con.GetPeerAvgRTT(PEER_ID_SERVER);
+ } catch(con::PeerNotFoundException &e){
+ return 1337;
+ }
}
View
@@ -251,11 +251,11 @@ class Client : public con::PeerHandler, public InventoryManager
float getAvgRtt()
{
- //JMutexAutoLock lock(m_con_mutex); //bulk comment-out
- con::Peer *peer = m_con.GetPeerNoEx(PEER_ID_SERVER);
- if(peer == NULL)
- return 0.0;
- return peer->avg_rtt;
+ try{
+ return m_con.GetPeerAvgRTT(PEER_ID_SERVER);
+ } catch(con::PeerNotFoundException){
+ return 1337;
+ }
}
bool getChatMessage(std::wstring &message)
Oops, something went wrong.

0 comments on commit 4b6138e

Please sign in to comment.