-
-
Save nielsmh/1419be0703c75c7e321a00ce6c94debc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- a/src/network/network_udp.cpp | |
+++ b/src/network/network_udp.cpp | |
@@ -646,7 +646,9 @@ void NetworkUDPClose() | |
/** Receive the UDP packets. */ | |
void NetworkBackgroundUDPLoop() | |
{ | |
- std::lock_guard<std::mutex> lock(_network_udp_mutex); | |
+ /* Try to take the lock, but do nothing if the mutex is already held. Avoid blocking the main network loop. */ | |
+ if (!_network_udp_mutex.try_lock()) return; | |
+ std::lock_guard<std::mutex> lock(_network_udp_mutex, std::adopt_lock); | |
if (_network_udp_server) { | |
_udp_server_socket->ReceivePackets(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment