race and leak fight
This commit is contained in:
parent
493c7608a6
commit
cff451c6f9
@ -10,7 +10,7 @@
|
||||
|
||||
# Minimal supported version: 1.1.0
|
||||
if(NOT CMAKE_CXX_COMPILER_VERSION OR (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7))
|
||||
message(WARNING "Use system msgpack can be too old. recommended min version=1.1.0")
|
||||
message(WARNING "Using system msgpack (compiler too old). it can be too old. recommended min version=1.1.0")
|
||||
set(ENABLE_SYSTEM_MSGPACK 1)
|
||||
endif()
|
||||
|
||||
|
@ -538,8 +538,10 @@ void Client::step(float dtime)
|
||||
MinimapMapblock *minimap_mapblock = nullptr;
|
||||
if(block) {
|
||||
block->setMesh(r.mesh);
|
||||
if (r.mesh)
|
||||
if (r.mesh) {
|
||||
minimap_mapblock = r.mesh->getMinimapMapblock();
|
||||
r.mesh->m_minimap_mapblock = nullptr;
|
||||
}
|
||||
}
|
||||
m_mapper->addBlock(r.p, minimap_mapblock);
|
||||
if (porting::getTimeMs() > end_ms) {
|
||||
|
@ -521,6 +521,9 @@ void *EmergeThread::Thread()
|
||||
VoxelArea(minp, maxp));
|
||||
*/
|
||||
try { // takes about 90ms with -O1 on an e3-1230v2
|
||||
#if !ENABLE_THREADS
|
||||
auto lock = map->m_nothread_locker.lock_unique_rec();
|
||||
#endif
|
||||
m_server->getScriptIface()->environment_OnGenerated(
|
||||
minp, maxp, mapgen->blockseed);
|
||||
} catch(LuaError &e) {
|
||||
|
@ -2041,6 +2041,8 @@ void ServerEnvironment::activateObjects(MapBlock *block, u32 dtime_s)
|
||||
if(block == NULL)
|
||||
return;
|
||||
|
||||
//auto lock = block->m_static_objects.m_active.lock_unique_rec();
|
||||
|
||||
// Ignore if no stored objects (to not set changed flag)
|
||||
if(block->m_static_objects.m_stored.empty())
|
||||
return;
|
||||
|
@ -1114,15 +1114,15 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
|
||||
m_usage_timer(0)
|
||||
{
|
||||
m_mesh = new scene::SMesh();
|
||||
m_minimap_mapblock = new MinimapMapblock();
|
||||
|
||||
m_enable_shaders = data->m_use_shaders;
|
||||
m_enable_highlighting = g_settings->getBool("enable_node_highlighting");
|
||||
|
||||
if (!data->fill_data())
|
||||
return;
|
||||
|
||||
if (step == 1)
|
||||
if (g_settings->getBool("enable_minimap")) {
|
||||
m_minimap_mapblock = new MinimapMapblock();
|
||||
v3s16 blockpos_nodes = data->m_blockpos * MAP_BLOCKSIZE;
|
||||
for(s16 x = 0; x < MAP_BLOCKSIZE; x++) {
|
||||
for(s16 z = 0; z < MAP_BLOCKSIZE; z++) {
|
||||
@ -1393,6 +1393,9 @@ MapBlockMesh::~MapBlockMesh()
|
||||
}
|
||||
m_mesh->drop();
|
||||
m_mesh = NULL;
|
||||
|
||||
if (m_minimap_mapblock)
|
||||
delete m_minimap_mapblock;
|
||||
}
|
||||
|
||||
void MapBlockMesh::setStatic()
|
||||
|
@ -175,7 +175,9 @@ public:
|
||||
|
||||
private:
|
||||
scene::SMesh *m_mesh;
|
||||
public:
|
||||
MinimapMapblock *m_minimap_mapblock;
|
||||
private:
|
||||
IGameDef *m_gamedef;
|
||||
ITextureSource *m_tsrc;
|
||||
IShaderSource *m_shdrsrc;
|
||||
|
@ -37,6 +37,7 @@ QueuedMinimapUpdate::QueuedMinimapUpdate():
|
||||
|
||||
QueuedMinimapUpdate::~QueuedMinimapUpdate()
|
||||
{
|
||||
if (data)
|
||||
delete data;
|
||||
}
|
||||
|
||||
@ -117,12 +118,15 @@ void MinimapUpdateThread::doUpdate()
|
||||
QueuedMinimapUpdate *q = m_queue.pop();
|
||||
std::map<v3s16, MinimapMapblock *>::iterator it;
|
||||
it = m_blocks_cache.find(q->pos);
|
||||
if (it != m_blocks_cache.end())
|
||||
delete it->second;
|
||||
if (q->data) {
|
||||
m_blocks_cache[q->pos] = q->data;
|
||||
q->data = nullptr;
|
||||
} else if (it != m_blocks_cache.end()) {
|
||||
delete it->second;
|
||||
m_blocks_cache.erase(it);
|
||||
}
|
||||
delete q;
|
||||
}
|
||||
if (data->map_invalidated) {
|
||||
if (data->mode != MINIMAP_MODE_OFF) {
|
||||
|
@ -31,10 +31,8 @@ ObjDefManager::ObjDefManager(IGameDef *gamedef, ObjDefType type)
|
||||
|
||||
ObjDefManager::~ObjDefManager()
|
||||
{
|
||||
/* leak!
|
||||
for (size_t i = 0; i != m_objects.size(); i++)
|
||||
delete m_objects[i];
|
||||
but no crash */
|
||||
m_objects.clear();
|
||||
}
|
||||
|
||||
|
@ -32,9 +32,17 @@ along with Freeminer. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "common/c_internal.h"
|
||||
#include "cpp_api/s_base.h"
|
||||
#include "config.h"
|
||||
|
||||
#if ENABLE_THREADS
|
||||
#define SCRIPTAPI_LOCK auto _script_lock = std::unique_lock<std::recursive_mutex> (this->m_luastackmutex)
|
||||
#else
|
||||
#define SCRIPTAPI_LOCK
|
||||
#endif
|
||||
|
||||
|
||||
#define SCRIPTAPI_PRECHECKHEADER \
|
||||
auto _script_lock = std::unique_lock<std::recursive_mutex> (this->m_luastackmutex); \
|
||||
SCRIPTAPI_LOCK; \
|
||||
realityCheck(); \
|
||||
lua_State *L = getStack(); \
|
||||
StackUnroller stack_unroller(L);
|
||||
|
@ -255,9 +255,11 @@ public:
|
||||
|
||||
porting::setThreadName(thread_name);
|
||||
|
||||
porting::setThreadPriority(30);
|
||||
|
||||
while (!StopRequested()) {
|
||||
|
||||
m_update_sem.Wait();
|
||||
m_update_sem.Wait(1000);
|
||||
|
||||
// Empty the queue, just in case doUpdate() is expensive
|
||||
while (m_update_sem.GetValue()) m_update_sem.Wait();
|
||||
|
Loading…
x
Reference in New Issue
Block a user