mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-05-30 16:16:18 +00:00
Restore recursive locking for mutexes converted from CRITICAL_SECTION
CRITICAL_SECTION is reentrant; std::mutex is not. This caused deadlocks during world generation, post-processing, and saving.
This commit is contained in:
@@ -144,7 +144,7 @@ LevelChunk* ServerChunkCache::create(
|
||||
LevelChunk* lastChunk = chunk;
|
||||
|
||||
if ((chunk == nullptr) || (chunk->x != x) || (chunk->z != z)) {
|
||||
{ std::lock_guard<std::mutex> lock(m_csLoadCreate);
|
||||
{ std::lock_guard<std::recursive_mutex> lock(m_csLoadCreate);
|
||||
chunk = load(x, z);
|
||||
if (chunk == nullptr) {
|
||||
if (source == nullptr) {
|
||||
@@ -169,7 +169,7 @@ LevelChunk* ServerChunkCache::create(
|
||||
#endif
|
||||
{
|
||||
// Successfully updated the cache
|
||||
std::lock_guard<std::mutex> lock(m_csLoadCreate);
|
||||
std::lock_guard<std::recursive_mutex> lock(m_csLoadCreate);
|
||||
// 4J - added - this will run a recalcHeightmap if source is a
|
||||
// randomlevelsource, which has been split out from source::getChunk
|
||||
// so that we are doing it after the chunk has been added to the
|
||||
@@ -649,7 +649,7 @@ bool ServerChunkCache::saveAllEntities() {
|
||||
PIXBeginNamedEvent(0, "Save all entities");
|
||||
|
||||
PIXBeginNamedEvent(0, "saving to NBT");
|
||||
{ std::lock_guard<std::mutex> lock(m_csLoadCreate);
|
||||
{ std::lock_guard<std::recursive_mutex> lock(m_csLoadCreate);
|
||||
for (auto it = m_loadedChunkList.begin(); it != m_loadedChunkList.end();
|
||||
++it) {
|
||||
storage->saveEntities(level, *it);
|
||||
@@ -666,7 +666,7 @@ bool ServerChunkCache::saveAllEntities() {
|
||||
}
|
||||
|
||||
bool ServerChunkCache::save(bool force, ProgressListener* progressListener) {
|
||||
std::lock_guard<std::mutex> lock(m_csLoadCreate);
|
||||
std::lock_guard<std::recursive_mutex> lock(m_csLoadCreate);
|
||||
int saves = 0;
|
||||
|
||||
// 4J - added this to support progressListner
|
||||
|
||||
Reference in New Issue
Block a user