]> git.lizzy.rs Git - minetest.git/commitdiff
Server GotBlocks(): Lock clients to avoid multithreading issues
authorSmallJoker <mk939@ymail.com>
Tue, 2 Feb 2021 18:10:35 +0000 (19:10 +0100)
committerSmallJoker <mk939@ymail.com>
Tue, 2 Feb 2021 18:10:35 +0000 (19:10 +0100)
src/network/serverpackethandler.cpp

index 882cf71c16311ef091f613c4fede37ab89f80454..4d79f375c7028ef5e47eba16c26bed91b594f22d 100644 (file)
@@ -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,