mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
Server GotBlocks(): Lock clients to avoid multithreading issues
This commit is contained in:
parent
40ad976753
commit
7ebd5da9cd
1 changed files with 4 additions and 2 deletions
|
@ -438,18 +438,20 @@ void Server::handleCommand_GotBlocks(NetworkPacket* pkt)
|
||||||
u8 count;
|
u8 count;
|
||||||
*pkt >> count;
|
*pkt >> count;
|
||||||
|
|
||||||
RemoteClient *client = getClient(pkt->getPeerId());
|
|
||||||
|
|
||||||
if ((s16)pkt->getSize() < 1 + (int)count * 6) {
|
if ((s16)pkt->getSize() < 1 + (int)count * 6) {
|
||||||
throw con::InvalidIncomingDataException
|
throw con::InvalidIncomingDataException
|
||||||
("GOTBLOCKS length is too short");
|
("GOTBLOCKS length is too short");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_clients.lock();
|
||||||
|
RemoteClient *client = m_clients.lockedGetClientNoEx(pkt->getPeerId());
|
||||||
|
|
||||||
for (u16 i = 0; i < count; i++) {
|
for (u16 i = 0; i < count; i++) {
|
||||||
v3s16 p;
|
v3s16 p;
|
||||||
*pkt >> p;
|
*pkt >> p;
|
||||||
client->GotBlock(p);
|
client->GotBlock(p);
|
||||||
}
|
}
|
||||||
|
m_clients.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::process_PlayerPos(RemotePlayer *player, PlayerSAO *playersao,
|
void Server::process_PlayerPos(RemotePlayer *player, PlayerSAO *playersao,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue