diff options
author | SmallJoker <SmallJoker@users.noreply.github.com> | 2020-03-26 19:13:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-26 19:13:50 +0100 |
commit | a0998754a7bee2dfa98ddfcdf574803185a1896f (patch) | |
tree | 46fed7cf4f613d3e83c2c9ef467ece0523f53945 | |
parent | f7c7353a9a9446a2fb6b3b0cb24deec0851d7291 (diff) | |
download | minetest-a0998754a7bee2dfa98ddfcdf574803185a1896f.tar.gz minetest-a0998754a7bee2dfa98ddfcdf574803185a1896f.tar.bz2 minetest-a0998754a7bee2dfa98ddfcdf574803185a1896f.zip |
Connection: Fix deadlock in debug mode (#9550)
-rw-r--r-- | src/network/connection.cpp | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/src/network/connection.cpp b/src/network/connection.cpp index a99e5b145..36124ce3c 100644 --- a/src/network/connection.cpp +++ b/src/network/connection.cpp @@ -41,17 +41,23 @@ namespace con /* defines used for debugging and profiling */ /******************************************************************************/ #ifdef NDEBUG -#define LOG(a) a -#define PROFILE(a) + #define LOG(a) a + #define PROFILE(a) #else -/* this mutex is used to achieve log message consistency */ -std::mutex log_message_mutex; -#define LOG(a) \ - { \ - MutexAutoLock loglock(log_message_mutex); \ - a; \ - } -#define PROFILE(a) a + #if 0 + /* this mutex is used to achieve log message consistency */ + std::mutex log_message_mutex; + #define LOG(a) \ + { \ + MutexAutoLock loglock(log_message_mutex); \ + a; \ + } + #else + // Prevent deadlocks until a solution is found after 5.2.0 (TODO) + #define LOG(a) a + #endif + + #define PROFILE(a) a #endif #define PING_TIMEOUT 5.0 @@ -1073,6 +1079,10 @@ bool UDPPeer::processReliableSendCommand( FATAL_ERROR_IF(!successfully_put_back_sequence_number, "error"); } + // DO NOT REMOVE n_queued! It avoids a deadlock of async locked + // 'log_message_mutex' and 'm_list_mutex'. + u32 n_queued = channels[c.channelnum].outgoing_reliables_sent.size(); + LOG(dout_con<<m_connection->getDesc() << " Windowsize exceeded on reliable sending " << c.data.getSize() << " bytes" @@ -1081,7 +1091,7 @@ bool UDPPeer::processReliableSendCommand( << std::endl << "\t\tgot at most : " << packets_available << " packets" << std::endl << "\t\tpackets queued : " - << channels[c.channelnum].outgoing_reliables_sent.size() + << n_queued << std::endl); return false; |