From d12f967f32bfd102b38c303c8225735938566aac Mon Sep 17 00:00:00 2001 From: Sebastian Hahta <joseha@utu.fi> Date: Mon, 27 Jan 2020 14:39:22 +0200 Subject: [PATCH] fix RPC callbacks --- components/net/cpp/include/ftl/net/peer.hpp | 4 ++-- components/net/cpp/src/peer.cpp | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/components/net/cpp/include/ftl/net/peer.hpp b/components/net/cpp/include/ftl/net/peer.hpp index 457471747..9978da922 100644 --- a/components/net/cpp/include/ftl/net/peer.hpp +++ b/components/net/cpp/include/ftl/net/peer.hpp @@ -266,7 +266,7 @@ class Peer { //std::vector<std::function<void(Peer &)>> close_handlers_; std::map<int, std::unique_ptr<virtual_caller>> callbacks_; - static int rpcid__; // Return ID for RPC calls + static volatile int rpcid__; // Return ID for RPC calls }; // --- Inline Template Implementations ----------------------------------------- @@ -361,7 +361,7 @@ int Peer::asyncCall( std::function<void(const T&)> cb, ARGS... args) { auto args_obj = std::make_tuple(args...); - auto rpcid = 0; + uint32_t rpcid = 0; { // Could this be the problem???? diff --git a/components/net/cpp/src/peer.cpp b/components/net/cpp/src/peer.cpp index 0335ca67f..8f280bad4 100644 --- a/components/net/cpp/src/peer.cpp +++ b/components/net/cpp/src/peer.cpp @@ -59,7 +59,7 @@ using std::vector; return ss.str(); }*/ -int Peer::rpcid__ = 0; +volatile int Peer::rpcid__ = 0; // Global peer UUID ftl::UUID ftl::net::this_peer; @@ -548,7 +548,6 @@ void Peer::_dispatchResponse(uint32_t id, msgpack::object &res) { // TODO: Handle error reporting... UNIQUE_LOCK(cb_mtx_,lk); if (callbacks_.count(id) > 0) { - //DLOG(1) << "Received return RPC value"; // Allow for unlock before callback auto cb = std::move(callbacks_[id]); -- GitLab