fix: json thread safe
This commit is contained in:
parent
e6d59f05cc
commit
d027243a19
|
@ -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_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue