Commit 745d70b1abea16d3b9223c824e897ec957b5a80c
1 parent
87ff584e
Changed usages of commands_created_ so that it is an atomic fetch and add. Other…
…wise problems could occur where you increment, then fetch and get the wrong number.
Showing
1 changed file
with
2 additions
and
3 deletions
include/redox/client.hpp
| ... | ... | @@ -400,9 +400,8 @@ Command<ReplyT> &Redox::createCommand(const std::vector<std::string> &cmd, |
| 400 | 400 | } |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | - commands_created_ += 1; | |
| 404 | - auto *c = new Command<ReplyT>(this, commands_created_, cmd, callback, repeat, after, free_memory, | |
| 405 | - logger_); | |
| 403 | + auto *c = new Command<ReplyT>(this, std::atomic_fetch_add(commands_created_, 1), cmd, | |
| 404 | + callback, repeat, after, free_memory, logger_); | |
| 406 | 405 | |
| 407 | 406 | std::lock_guard<std::mutex> lg(queue_guard_); |
| 408 | 407 | std::lock_guard<std::mutex> lg2(command_map_guard_); | ... | ... |