Commit 87ff584e91893e22a4e3232c7ee3a58c13a246e3
1 parent
91e3e06c
Fixed usage of running_ that did not include a lock.
Showing
1 changed file
with
5 additions
and
3 deletions
include/redox/client.hpp
| @@ -393,9 +393,11 @@ template <class ReplyT> | @@ -393,9 +393,11 @@ template <class ReplyT> | ||
| 393 | Command<ReplyT> &Redox::createCommand(const std::vector<std::string> &cmd, | 393 | Command<ReplyT> &Redox::createCommand(const std::vector<std::string> &cmd, |
| 394 | const std::function<void(Command<ReplyT> &)> &callback, | 394 | const std::function<void(Command<ReplyT> &)> &callback, |
| 395 | double repeat, double after, bool free_memory) { | 395 | double repeat, double after, bool free_memory) { |
| 396 | - | ||
| 397 | - if (!running_) { | ||
| 398 | - throw std::runtime_error("[ERROR] Need to connect Redox before running commands!"); | 396 | + { |
| 397 | + unique_lock<mutex> ul(running_lock_); | ||
| 398 | + if (!running_) { | ||
| 399 | + throw std::runtime_error("[ERROR] Need to connect Redox before running commands!"); | ||
| 400 | + } | ||
| 399 | } | 401 | } |
| 400 | 402 | ||
| 401 | commands_created_ += 1; | 403 | commands_created_ += 1; |