diff options
author | sapier <Sapier at GMX dot net> | 2013-11-30 21:22:15 +0100 |
---|---|---|
committer | sapier <Sapier at GMX dot net> | 2013-11-30 21:22:15 +0100 |
commit | de0cdbc01cc39e4f89a9d012661031a66ba3294f (patch) | |
tree | 1d6e4bb56c41cd136028a5df896247225eb54820 /src/log.cpp | |
parent | e605d7025608f8d04cdd6143c6be85e35ef067e3 (diff) | |
download | minetest-de0cdbc01cc39e4f89a9d012661031a66ba3294f.tar.gz minetest-de0cdbc01cc39e4f89a9d012661031a66ba3294f.tar.bz2 minetest-de0cdbc01cc39e4f89a9d012661031a66ba3294f.zip |
Fix log threadname lookup handling not beeing threadsafe
Diffstat (limited to 'src/log.cpp')
-rw-r--r-- | src/log.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/log.cpp b/src/log.cpp index 366d83b64..527f54480 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -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; |