Skip to content

Commit

Permalink
fix: json thread safe
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexays committed May 2, 2019
1 parent e6d59f0 commit d027243
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/modules/sway/ipc/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class Ipc {
int fd_event_;
std::mutex mutex_;
std::mutex mutex_event_;
std::mutex mutex_parser_;
util::JsonParser parser_;
};

Expand Down
1 change: 1 addition & 0 deletions src/modules/sway/ipc/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ struct Ipc::ipc_response Ipc::recv(int fd) {
}
total += res;
}
std::lock_guard<std::mutex> lock(mutex_parser_);
auto parsed = parser_.parse(&payload.front());
return {data32[0], data32[1], parsed};
}
Expand Down

0 comments on commit d027243

Please sign in to comment.