Skip to content

Commit 7ebd5da

Browse files
committedFeb 2, 2021
Server GotBlocks(): Lock clients to avoid multithreading issues
1 parent 40ad976 commit 7ebd5da

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed
 

‎src/network/serverpackethandler.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -438,18 +438,20 @@ void Server::handleCommand_GotBlocks(NetworkPacket* pkt)
438438
u8 count;
439439
*pkt >> count;
440440

441-
RemoteClient *client = getClient(pkt->getPeerId());
442-
443441
if ((s16)pkt->getSize() < 1 + (int)count * 6) {
444442
throw con::InvalidIncomingDataException
445443
("GOTBLOCKS length is too short");
446444
}
447445

446+
m_clients.lock();
447+
RemoteClient *client = m_clients.lockedGetClientNoEx(pkt->getPeerId());
448+
448449
for (u16 i = 0; i < count; i++) {
449450
v3s16 p;
450451
*pkt >> p;
451452
client->GotBlock(p);
452453
}
454+
m_clients.unlock();
453455
}
454456

455457
void Server::process_PlayerPos(RemotePlayer *player, PlayerSAO *playersao,

0 commit comments

Comments
 (0)
Please sign in to comment.