diff options
author | sfan5 <sfan5@live.de> | 2022-01-09 20:43:25 +0100 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2022-01-15 17:45:08 +0100 |
commit | 379473b67007abf78d87ebbaf925b4948cf72ae6 (patch) | |
tree | da9d61ddec9c494e2e18301b2370be142d19662a /src/server.cpp | |
parent | 72b14bd994659163d4c2ea0d769d329df8a0f937 (diff) | |
download | minetest-379473b67007abf78d87ebbaf925b4948cf72ae6.tar.gz minetest-379473b67007abf78d87ebbaf925b4948cf72ae6.tar.bz2 minetest-379473b67007abf78d87ebbaf925b4948cf72ae6.zip |
Improve situation around race condition with dynamic_add_media during client join
Diffstat (limited to 'src/server.cpp')
-rw-r--r-- | src/server.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/server.cpp b/src/server.cpp index 45156db61..fdf02ed50 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -3534,8 +3534,22 @@ bool Server::dynamicAddMedia(std::string filepath, std::unordered_set<session_t> delivered, waiting; m_clients.lock(); for (auto &pair : m_clients.getClientList()) { - if (pair.second->getState() < CS_DefinitionsSent) + if (pair.second->getState() == CS_DefinitionsSent && !ephemeral) { + /* + If a client is in the DefinitionsSent state it is too late to + transfer the file via sendMediaAnnouncement() but at the same + time the client cannot accept a media push yet. + Short of artificially delaying the joining process there is no + way for the server to resolve this so we (currently) opt not to. + */ + warningstream << "The media \"" << filename << "\" (dynamic) could " + "not be delivered to " << pair.second->getName() + << " due to a race condition." << std::endl; continue; + } + if (pair.second->getState() < CS_Active) + continue; + const auto proto_ver = pair.second->net_proto_version; if (proto_ver < 39) continue; |