From 745d70b1abea16d3b9223c824e897ec957b5a80c Mon Sep 17 00:00:00 2001 From: Bryan Dallas Date: Tue, 1 Sep 2015 10:55:19 -0400 Subject: [PATCH] Changed usages of commands_created_ so that it is an atomic fetch and add. Otherwise problems could occur where you increment, then fetch and get the wrong number. --- include/redox/client.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/redox/client.hpp b/include/redox/client.hpp index 43cfc63..6bfca27 100644 --- a/include/redox/client.hpp +++ b/include/redox/client.hpp @@ -400,9 +400,8 @@ Command &Redox::createCommand(const std::vector &cmd, } } - commands_created_ += 1; - auto *c = new Command(this, commands_created_, cmd, callback, repeat, after, free_memory, - logger_); + auto *c = new Command(this, std::atomic_fetch_add(commands_created_, 1), cmd, + callback, repeat, after, free_memory, logger_); std::lock_guard lg(queue_guard_); std::lock_guard lg2(command_map_guard_); -- libgit2 0.21.4