fix: json thread safe

This commit is contained in:
Alex 2019-05-02 14:24:37 +02:00
parent e6d59f05cc
commit d027243a19
2 changed files with 2 additions and 0 deletions

View File

@ -44,6 +44,7 @@ class Ipc {
int fd_event_; int fd_event_;
std::mutex mutex_; std::mutex mutex_;
std::mutex mutex_event_; std::mutex mutex_event_;
std::mutex mutex_parser_;
util::JsonParser parser_; util::JsonParser parser_;
}; };

View File

@ -104,6 +104,7 @@ struct Ipc::ipc_response Ipc::recv(int fd) {
} }
total += res; total += res;
} }
std::lock_guard<std::mutex> lock(mutex_parser_);
auto parsed = parser_.parse(&payload.front()); auto parsed = parser_.parse(&payload.front());
return {data32[0], data32[1], parsed}; return {data32[0], data32[1], parsed};
} }