@@ -95,8 +95,6 @@ void *ServerThread::run()
95
95
96
96
while (!stopRequested ()) {
97
97
try {
98
- // TimeTaker timer("AsyncRunStep() + Receive()");
99
-
100
98
m_server->AsyncRunStep ();
101
99
102
100
m_server->Receive ();
@@ -989,23 +987,17 @@ void Server::Receive()
989
987
m_con.Receive (&pkt);
990
988
peer_id = pkt.getPeerId ();
991
989
ProcessData (&pkt);
992
- }
993
- catch (con::InvalidIncomingDataException &e) {
994
- infostream<<" Server::Receive(): "
995
- " InvalidIncomingDataException: what()="
996
- <<e.what ()<<std::endl;
997
- }
998
- catch (SerializationError &e) {
999
- infostream<<" Server::Receive(): "
1000
- " SerializationError: what()="
1001
- <<e.what ()<<std::endl;
1002
- }
1003
- catch (ClientStateError &e) {
990
+ } catch (const con::InvalidIncomingDataException &e) {
991
+ infostream << " Server::Receive(): InvalidIncomingDataException: what()="
992
+ << e.what () << std::endl;
993
+ } catch (const SerializationError &e) {
994
+ infostream << " Server::Receive(): SerializationError: what()="
995
+ << e.what () << std::endl;
996
+ } catch (const ClientStateError &e) {
1004
997
errorstream << " ProcessData: peer=" << peer_id << e.what () << std::endl;
1005
998
DenyAccess_Legacy (peer_id, L" Your client sent something server didn't expect."
1006
999
L" Try reconnecting or updating your client" );
1007
- }
1008
- catch (con::PeerNotFoundException &e) {
1000
+ } catch (const con::PeerNotFoundException &e) {
1009
1001
// Do nothing
1010
1002
}
1011
1003
}
@@ -2259,29 +2251,30 @@ void Server::SendBlocks(float dtime)
2259
2251
std::sort (queue.begin (), queue.end ());
2260
2252
2261
2253
m_clients.lock ();
2262
- for (u32 i=0 ; i<queue.size (); i++)
2263
- {
2254
+ s32 max_blocks_to_send =
2255
+ g_settings->getS32 (" max_simultaneous_block_sends_server_total" );
2256
+
2257
+ for (const PrioritySortedBlockTransfer &block_to_send : queue) {
2264
2258
// TODO: Calculate limit dynamically
2265
- if (total_sending >= g_settings->getS32
2266
- (" max_simultaneous_block_sends_server_total" ))
2259
+ if (total_sending >= max_blocks_to_send)
2267
2260
break ;
2268
2261
2269
- PrioritySortedBlockTransfer q = queue[i];
2270
-
2271
2262
MapBlock *block = nullptr ;
2272
2263
try {
2273
- block = m_env->getMap ().getBlockNoCreate (q .pos );
2274
- } catch (const InvalidPositionException &e) {
2264
+ block = m_env->getMap ().getBlockNoCreate (block_to_send .pos );
2265
+ } catch (const InvalidPositionException &e) {
2275
2266
continue ;
2276
2267
}
2277
2268
2278
- RemoteClient *client = m_clients.lockedGetClientNoEx (q.peer_id , CS_Active);
2269
+ RemoteClient *client = m_clients.lockedGetClientNoEx (block_to_send.peer_id ,
2270
+ CS_Active);
2279
2271
if (!client)
2280
2272
continue ;
2281
2273
2282
- SendBlockNoLock (q.peer_id , block, client->serialization_version , client->net_proto_version );
2274
+ SendBlockNoLock (block_to_send.peer_id , block, client->serialization_version ,
2275
+ client->net_proto_version );
2283
2276
2284
- client->SentBlock (q .pos );
2277
+ client->SentBlock (block_to_send .pos );
2285
2278
total_sending++;
2286
2279
}
2287
2280
m_clients.unlock ();
0 commit comments