Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Server GotBlocks(): Lock clients to avoid multithreading issues
  • Loading branch information
SmallJoker committed Feb 2, 2021
1 parent 40ad976 commit 7ebd5da
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/network/serverpackethandler.cpp
Expand Up @@ -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,
Expand Down

0 comments on commit 7ebd5da

Please sign in to comment.