Skip to content

Commit

Permalink
thread-safety fixes: PooledString, layer metadata (#761)
Browse files Browse the repository at this point in the history
  • Loading branch information
cldellow authored Sep 23, 2024
1 parent 7f03430 commit 142b38b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/osm_lua_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const std::string EMPTY_STRING = "";
thread_local kaguya::State *g_luaState = nullptr;
thread_local OsmLuaProcessing* osmLuaProcessing = nullptr;

std::mutex vectorLayerMetadataMutex;

void handleOsmLuaProcessingUserSignal(int signum) {
osmLuaProcessing->handleUserSignal(signum);
}
Expand Down Expand Up @@ -913,6 +915,7 @@ std::string OsmLuaProcessing::FindInRelation(const std::string &key) {

// Record attribute name/type for vector_layers table
void OsmLuaProcessing::setVectorLayerMetadata(const uint_least8_t layer, const string &key, const uint type) {
std::lock_guard<std::mutex> lock(vectorLayerMetadataMutex);
layers.layers[layer].attributeMap[key] = type;
}

Expand Down
3 changes: 2 additions & 1 deletion src/pooled_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
#include <stdexcept>
#include <mutex>
#include <cstring>
#include <deque>

namespace PooledStringNS {
std::vector<char*> tables;
std::deque<char*> tables;
std::mutex mutex;

const uint8_t ShortString = 0b00;
Expand Down

0 comments on commit 142b38b

Please sign in to comment.