1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Fix log threadname lookup handling not beeing threadsafe

This commit is contained in:
sapier 2013-11-30 21:22:15 +01:00
parent e605d70256
commit de0cdbc01c
3 changed files with 19 additions and 21 deletions

View file

@ -29,6 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
std::list<ILogOutput*> log_outputs[LMT_NUM_VALUES];
std::map<threadid_t, std::string> log_threadnames;
JMutex log_threadnamemutex;
void log_add_output(ILogOutput *out, enum LogMessageLevel lev)
{
@ -60,13 +61,17 @@ void log_remove_output(ILogOutput *out)
void log_register_thread(const std::string &name)
{
threadid_t id = get_current_thread_id();
log_threadnamemutex.Lock();
log_threadnames[id] = name;
log_threadnamemutex.Unlock();
}
void log_deregister_thread()
{
threadid_t id = get_current_thread_id();
log_threadnamemutex.Lock();
log_threadnames.erase(id);
log_threadnamemutex.Unlock();
}
static std::string get_lev_string(enum LogMessageLevel lev)
@ -144,7 +149,7 @@ public:
}
m_buf += c;
}
private:
enum LogMessageLevel m_lev;
std::string m_buf;