diff options
author | SmallJoker <mk939@ymail.com> | 2021-02-02 19:10:35 +0100 |
---|---|---|
committer | SmallJoker <mk939@ymail.com> | 2021-02-02 19:10:35 +0100 |
commit | 7ebd5da9cd4a227dcdc140a495f264a97277b3a3 (patch) | |
tree | 1e1ad7c0489a376658255f652d81e62916b13333 /src/network | |
parent | 40ad9767531beb6cf2e8bd918c9c9ed5f2749320 (diff) | |
download | minetest-7ebd5da9cd4a227dcdc140a495f264a97277b3a3.tar.gz minetest-7ebd5da9cd4a227dcdc140a495f264a97277b3a3.tar.bz2 minetest-7ebd5da9cd4a227dcdc140a495f264a97277b3a3.zip |
Server GotBlocks(): Lock clients to avoid multithreading issues
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/serverpackethandler.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/network/serverpackethandler.cpp b/src/network/serverpackethandler.cpp index 882cf71c1..4d79f375c 100644 --- a/src/network/serverpackethandler.cpp +++ b/src/network/serverpackethandler.cpp @@ -438,18 +438,20 @@ void Server::handleCommand_GotBlocks(NetworkPacket* pkt) u8 count; *pkt >> count; - RemoteClient *client = getClient(pkt->getPeerId()); - if ((s16)pkt->getSize() < 1 + (int)count * 6) { throw con::InvalidIncomingDataException ("GOTBLOCKS length is too short"); } + m_clients.lock(); + RemoteClient *client = m_clients.lockedGetClientNoEx(pkt->getPeerId()); + for (u16 i = 0; i < count; i++) { v3s16 p; *pkt >> p; client->GotBlock(p); } + m_clients.unlock(); } void Server::process_PlayerPos(RemotePlayer *player, PlayerSAO *playersao, |